.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Regular Expression to Match

Posted By:      Posted Date: August 23, 2010    Points: 0   Category :ASP.Net

Here is the kind of text I want to match via a regular Expression

The id="dgSchedule" is always present in the TAG but its location may differ

The table is span over multiple line/contains white spaces/tabs...

I have the regular expression to match the start and end tag respectively over a single line

\<table .*\>


The problem is to match the whole table span over multiple lines

<table cellspacing="0" rules="all" border="1" id="dgSchedule" style="border-style:None;height:100%;width:100%;border-collapse:collapse;">
	<tr class="blackbar" align="center" style="background-color:#7FB4DE;font-family:Verdana;font-weight:bold;height:20px;">
		<td>From Place</td><td>To Place</td><td>Time</td><td>Bus Type</td>

	</tr><tr style="background-color:#DEECF5;">
	</tr><tr style="background-color:#EFF5FA;">
	</tr><tr style="background-color:#DEECF5;">


View Complete Post

More Related Resource Links

Regular Expression to match "="(45167)" and retrieve only the code inside parentheses



Need a Regular Expression to match "=&quot;(45167)" and retrieve only the code inside  parentheses say 45167

thanks in advance

Regular expression to match for -


I need my string to be a minimum of 8 character, begin with 3 alphanumber,  end in alphanumberic and contain atleast one -

Below is what I have that includes everything but testing for inlcusion of atleast one -


string example to work with...

abc-1234,  123-adjoq-jadfoqe, 123abc-a

Strings that should fail...

as-jdsdjf, a-a-dfa, acb-3gh, abc-1234-


Problem Excluding Section In Quotes From Regular Expression Match


Hi There,

Currently I have the string:

"WHERE Column_1_Name = 1 AND Column_2_Name = 'Test Column Criteria'"

& my desired matches are as follows:




However, so far, I can only achieve

'Test Column Criteria'

via: (([a-z][\w]+)|('[\w ]+'))(?!('[\w ]+'))




via (('[\w ]+')|([a-z][\w]+))(?<=\3)


All help appreciated much appreciated.

(I'm using the .net engine, case insensitive)

Regular expression for Ms Word HTML Markup


I am trying to create a regular expression that searchs for all html tags and attributes that start with 'mso', ending with a semi-colon.  If found, it would replace it with an empty string.

eg. Input string:

<span style="font-family: Arial, sans-serif; font-size: 11pt; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Times New Roman; mso-bidi-font-family: Times New Roman; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">My text goes here</span>


<span style="font-family: Arial, sans-serif; font-size: 11pt;">My text goes here</span>

All the attempts I have tried have yielded no results. I have tried: (\bmso)\w*[;]\b and this - \bmso\w+(?=;\b) among many other variations of the two.  Any help would be appreciated.


Regular expression for MS Word HTML Markup


I am trying to validate a rich text box to remove some ms word content but I want to keep the other attributes that are not MS office related.

input: <span style="font-size: 11pt; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: &#34;Times New Roman&#34;; mso-bidi-font-family: Times New Roman&#34;; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; font-family: Arial&#34;, &#34;sans-serif&#34;">mso-bidi-language: AR-SA; mso-My Text Here; mso-My Text Here2</span>

I first run this regex to remove the unformed html (\&\#34\;).  Then, I remove everything inside the =" ending with "

regex: (?<=\=\")(.*?)(?=\")
: <span font="" style="">mso-bidi-language: AR-SA; mso-My Text Here; mso-My Text Here2</span>

Now it removes everything inside the tags and not the text. With the following, it removes the matching pattern, but it also removes the text that i need and the end tags.

: <span font="font-size: 11pt;" style="font-family: Arial, sans-serif;">

When i try and combine the two expressions, it does not provide the correct output.

Regular Expression Match Exact String


I'm looking for a regular expression that satisfies one of the two conditions (Reg Expression OR Exact String Match W/ Underscores) listed below.





Thanks in advance

Can we use regular expression to match numbers not preceded by a specified set of characters


I have been trying to come up with a RegEx that would match numbers (including decimals and negative numbers) that are not preceded by a specified set of characters. For example:

Specified set of characters (not including comma): c, t

Input string: “This c2 is one element. And t-4a, d25, c2.54, v4.28, q58 are other elements”

Desired result (the numbers not preceded by c and t):

The pattern I tried: [^ct](-?\d+\.?\d*|\.\d+)

The matches I got (Note: I fetched the results from Group 1):


I don’t want the numbers in bold to be returned since in t-4a the integer -4 is preceded by t, and in c2.54, 2.54 is preceded by c.

Can we refine the above pattern or is it even possible?

Thank you.

How to match regular expression in c# with two grouped expressions

I would like to match a string separated by "/" followed by an expression like 1..100 and again string separated by "/" followed by 1..100, here is the string format.
here is my regular expression 
Regex regAppDH = new Regex(@"/String1/String2/String3/stirng4(\[[0-9]|[1-9][0-9]\])/string5/stirng6\[[0-9]|[1-9][0-9]\]")
This regular expression does not match after the first group expression ( before string5)  , can any body help to get this expression working.
stirng1,string2,string3,string4 and string5,string6 are alpha numeric and fixed. 


HTML Table Disable


I have a HTML Table that I use to place the control in so they display nicely on my Web Form.  I also use the Disable method to keep unwanted users from editing those controls based on their log in information, however I still want the information to be displayed for their review.

The information is displayed for example in the Text Boxes, however when they hit Enter on the form because the table is disabled for some reason the information is lost when I do my update to the SQL Server (the text box shows "")?

Why is it I can see the information on the screen, but the text box shows empty when hitting enter on the form?



Change grid view from table to other HTML layout



You'll have to excuse my ignorance, I'm coming at this from a front-end perspective, and don't really know how to deal with data views in ASP.NET.

Basically, I'm trying to change the layout of some repeated data from a straight table, to something more design-heavy.  It's the same data, just re-organised slightly.  The current ASP.NET code looks like this:

                    <asp:GridView ID="GVMoments" runat="server" AllowPaging="True" AllowSorting="True"
                        AutoGenerateColumns="False" PageSize="20" RowHeaderColumn="FirstName"
                        SkinID="GroupSkin" DataKeyNames="moment_id" 
                        <PagerSettings Mode="NumericFirstLast" PageButtonCount="20" Position="TopAndBottom" />
                        <RowStyle />
                                <asp:BoundField DataField="moment_id" HeaderText="moment_id" ReadOnly="True" SortExpression="moment_id"
                                    Visible="False" In

Model Binding the values in an HTML Table back to Controller / Model


Currently, I am working with ASP.NET MVC1 and am still learning about Model Binding and how values from a View are passed back to the Controller / Model. Specifically, I want take an existing Model, create a Table and populate the Rows of the Table, allow the user to edit some fields and pass it back.

In my example, I have a Class called "Ingredient" which has 4 public accessors:  Name, Barcode, Amount, and Unit

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<MvcACE.DomainModel.Entities.Ingredient>>" %>

<% using (Html.BeginForm("SubmitOrder","MyController"))
{ %>

<% if (Model != null)
foreach (var item in Model)
{ %>
<td><%= Html.Encode(item.Name)%></td>
<td><%= Html.Encode(item.Barcode)%></

blank row in HTML table?


 is there any way to inset a couple of blank rows into an html table, or do I need to create a separate <table> with a couple of <br> in between?

displaying the html table as a pdf document

well the question is simple but i searched all over, found crystal reports found many toolsbut the problem isi cannot use an other tools, or libraries other then the default with vs08 sp1i cannot use crystal reports, as its datasource is dataset or xml none of which is theremy page on users click of button generates a html table and info within using c# code behind (i.e. at runtime) so how to write this stream to browser such that it becomes a valid pdf file?

Help creating HTML table from dataTable when every nth dataTable row = 1 html table row... C#

Hello, Im trying to create an html table from data that is in a dataTable but Im having trouble coming up with the right logic. Every 3 rows in the dataTable needs to be 1 row in the html table.  Ive tried using foreach through the datatable with a modulus to determin every third dataTable row but i still run into snags because i am building the table using objects rather than using concatenated strings..(example TableRow tr = new TableRow  etc...). I cant add the cells to the rows when the row is only created in an if statement etc. Can someone post a good example in c# of how they would achieve this. The amount of data in the dataTable could change from time to time so the code cant rely on a pre determined size, unless you just need the total rows and columns, that can be dtermined when the dataTable is filled from the sqlDataReader. <table><tr><td>dataTable row 1 values</td><td>ataTable row 2 values</td><td>dataTable row 3 values</td></tr> <tr><td>dataTable row 4 values</td><td>dataTable row 5 values</td><td>dataTable row 6 values</td></tr>   Any help and example would be great. Ive been able to do similar tables in other apps but thats only when I use concatenated text strings to build the html table. Im trying to stay away from that this time

SQL PIVOT Table to regular sql table.

Hello, I have a fairly complex SP which produce a pivot table with dynamic columns. I was wondering if there is a way to copy that result table to another one with same columns/rows/data, except that the second table is actually stored in the database rather than just produced at runtime. I tried something like: SELECT * FROM (runtime_generated_PIVOT_Table) INTO (new_Table) but that did not work.... (probably didn't work because of the PIVOT table query, not sure)Steve

Wierd case of: Msg 213, Column name or number of supplied values does not match table definition

Hi, I'm working on several triggers (that happen after insert or update) in order to log the changes in a different table. They all follow a similar syntax and are working fine, except for this one... I've reduced the next code to the minimum that gives an error, so we can safely assume the other parts of the trigger are working fine. INSERT INTO [Adt].[WardUnitStayLog] SELECT t.* FROM [Adt].[WardUnitStay] t INNER JOIN inserted i ON i.[Id] = t.[Id]; I've used this same syntax (but on different tables) in other triggers, and these are working perfectly fine. The above query provides the next error: Column name or number of supplied values does not match table definition. I've checked both tables for differences in the columns, but to no avail... (I've checked them manually and by outerjoining the information_schema.columns) (I've also checked the order in wich these columns are defined, they match over the two tables) These are the creation scripts for the tables: CREATE TABLE [Adt].[WardUnitStay] ( [Id] [dbo].[Id] IDENTITY(1,1) NOT NULL, [UnifiedUnitStayId] [dbo].[Id] NOT NULL, [WardCd] [dbo].[Cd] NOT NULL, [_FirstAtTm] [dbo].[Dtm] NOT NULL, [_IsReservation] BIT NOT NULL, [_LastAtTm] [dbo].[Dtm] NOT NULL, [_LastBedCd] [dbo].[Cd] NULL, [_LastPhysicianUid]

Reviewer suggested common table expression instead of adding 12 fields

So during a code review a DB Mgr suggested that I use a common table function instead of adding the fields below. No idea how to possibly do this. Anyone have any ideas? Here is a code snippet that he wants to lose: SELECT   LP .leaseID, sum   (paymentAmount1+paymentAmount2+paymentAmount3+paymentAmount4+paymentAmount5+paymentAmount6+paymentAmount7+paymentAmount8+paymentAmount9+paymentAmount10+paymentAmount11+paymentAmount12) as restPayment FROM   leasePaymentScheduleDetails AS L inner join leasePaymentSchedules AS LP ON L.leasePaymentScheduleID = LP.leasePaymentScheduleID WHERE   paymentYear>=@curyear+5 GROUP   BY LP .leaseID   Any input is appreciated.
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend