Regular Expressions ForumDiscuss and ask questions concerning the usage of Regular Expressions (REGEXes) in the .NET Framework.© 2009 Microsoft Corporation. All rights reserved.Sun, 29 Nov 2009 21:00:55 Zd22c4513-a1d5-4186-9445-3be44591f4bfhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/29ae331c-6f29-42e3-b408-2f43f6919d37http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/29ae331c-6f29-42e3-b408-2f43f6919d37Kamran Shahidhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kamran%20ShahidRegular expression or String.substringI have a String<br/> abcdefghijklmnopqrstuvwxyz1234567890#<br/> <br/> Now I have to fill my object with certain substring starting from one point to other<br/> <br/> like<br/> <br/> obj1.Property1   = &quot;abcde&quot;;<br/> obj1.Property2   = &quot;fghijkl&quot;;<br/> obj1.Property3   = &quot;mnopqrstuvwxyz12&quot;;<br/> obj1.Property4   = &quot;34567890&quot;;<br/> <br/> <br/> Instead of String.Substring i want's to extract it using regular expression becuase the position of the <br/> string might later be changed so that i will only change the regular expression<br/> Please let me know is this approach is better or substring will be the better one as I might be dealing with millions of records<br/> which i have to fill to object to do some validation first<hr class="sig">Kamran Shahid Senior Software Engineer/Analyst (MCP,MCAD,MCSD.NET,MCTS,MCPD.net[web])Sun, 29 Nov 2009 21:00:54 Z2009-11-29T21:00:55Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/d0d56b53-e93d-443a-8475-29a1c6f077c9http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/d0d56b53-e93d-443a-8475-29a1c6f077c9Sengloryhttp://social.msdn.microsoft.com/Profile/en-US/?user=SengloryRegex that excludes specified entranceI need to write a regex validation that would pass text that DOESN'T contain a specified substring. For example, given five strings:<br/><br/>Arrowhead<br/>Arrival<br/>Parrot<br/>Rowland<br/>Melrow<br/><br/>This regex should pass all of them who don't contain ROW. So the proposed filtered output would be  :<br/><br/>Arrival<br/>Parrot<br/><br/><br/>How can I do this in the most elegant way?<br/><br/>Thanks.Wed, 25 Nov 2009 21:16:27 Z2009-11-29T19:52:43Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/5a26bb89-c0e4-4ca4-b0c7-220c5fe1f495http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/5a26bb89-c0e4-4ca4-b0c7-220c5fe1f495blue_devilhttp://social.msdn.microsoft.com/Profile/en-US/?user=blue_devilhow to get a html table using regex<p>Hi.</p> <p> </p> <p>I´m trying to get a table from a html document.</p> <p>There are more than one tables in this document and I only need one.</p> <p> </p> <p>The table is like this:</p> <p> </p> <p>&lt;table class=&quot;xxxx&quot; cellspacing=&quot;0&quot; align=&quot;center&quot;&gt;</p> <p>&lt;tr&gt;</p> <p>&lt;td align=&quot;left&quot;&gt;</p> <p>    &lt;a href=&quot;hhhhhhhhhhhh&quot;&gt;&lt;/a&gt;</p> <p>    &lt;b&gt;JJJJJJJJJJ&lt;/b&gt;</p> <p>&lt;/td&gt;</p> <p>&lt;td align=&quot;left&quot;&gt;</p> <p>    &lt;a href=&quot;hhhhhhhhhhhh&quot;&gt;&lt;/a&gt;</p> <p>    &lt;b&gt;JJJJJJJJJJ&lt;/b&gt;</p> <p>&lt;/td&gt;</p> <p>&lt;/tr&gt;</p> <p> </p> <p>&lt;tr&gt;</p> <p>&lt;td align=&quot;left&quot;&gt;</p> <p>    &lt;a href=&quot;hhhhhhhhhhhh&quot;&gt;&lt;/a&gt;</p> <p>    &lt;b&gt;JJJJJJJJJJ&lt;/b&gt;</p> <p>&lt;/td&gt;</p> <p>&lt;td align=&quot;left&quot;&gt;</p> <p>    &lt;a href=&quot;hhhhhhhhhhhh&quot;&gt;&lt;/a&gt;</p> <p>    &lt;b&gt;JJJJJJJJJJ&lt;/b&gt;</p> <p>&lt;/td&gt;</p> <p>&lt;/tr&gt;</p> <p>&lt;/table&gt;</p> <p> </p> <p>I want to get the information named &quot;hhhhhhhhhh&quot; and JJJJJJJJJJJ from all the table using a regular expression and I don´t know how to do it.</p> <p> </p> <p>I need help.</p> <p> </p> <p>Thanks.</p>Sat, 14 Apr 2007 18:29:17 Z2009-11-29T19:26:56Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/3fc08cb4-413e-4c62-8801-754e3eecc052http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/3fc08cb4-413e-4c62-8801-754e3eecc052a.Net_Phoenixhttp://social.msdn.microsoft.com/Profile/en-US/?user=a.Net_Phoenixsplit string logicHi,<br/><br/>I get a sql string like  <span style="text-decoration:underline"><strong>select ID,&quot; </strong></span><a href="http://localhost/TestSite/"><strong>http://localhost/TestSite/</strong></a><span style="text-decoration:underline"><strong>&quot; + MESTNR + &quot;.doc&quot; from TestMestLayer <br/><br/></strong></span>I need to split the string and rearrange them into two different string as  <strong><span style="text-decoration:underline">select ID,MESTNR from TestMestLAyer</span></strong> and <a href="http://localhost/TestSite/MestNR.doc"><strong>http://localhost/TestSite/MestNR.doc</strong></a> . There can be any number of columns used in the sql select statement but there will be only one column appended with url path. I could not find any appropriate logic that helps in all scenarios. Please help me with some algorithm or logic to accomplish this task.<hr class="sig">Regards, PhoenixTue, 24 Nov 2009 09:57:35 Z2009-11-27T09:02:33Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/eb6b0668-ff85-42fb-8140-60f1945e05d6http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/eb6b0668-ff85-42fb-8140-60f1945e05d6meetjaydeep3http://social.msdn.microsoft.com/Profile/en-US/?user=meetjaydeep3Regular Expression to restrict exe and batch fileI want regular expression which will restrict exe and batch extensions <hr class="sig">Regards,<br/> <a href="http://www.google.com/profiles/meetjaydeep">Jaydeep</a>Mon, 23 Nov 2009 09:27:20 Z2009-11-27T08:44:42Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/0aecfeb7-f25f-4700-93ec-e86013ccbe1chttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/0aecfeb7-f25f-4700-93ec-e86013ccbe1cjulsbarneshttp://social.msdn.microsoft.com/Profile/en-US/?user=julsbarnesregex to exclude integer in URL greater thanI need to exclude URLs that have a common value greater {ARTICLE_ID} &gt; 2,000:<br/> <br/> <table style="border-collapse:collapse;width:602pt" border=0 cellspacing=0 cellpadding=0 width=803> <col style="width:602pt" width=803> <tr style="height:12.75pt" height=17> <td class=xl24 style="height:12.75pt;width:602pt" width=803 height=17>regexpIgnoreCase:http://X\\.X\\.co.uk/.*CMD=VIEW_ARTICLE&amp;ARTICLE_ID=^\d{4}</td> </tr> </table> <br/> I tried the above to at least exclude all &gt; 9,999 but even that doesn't work, any ideas please?Thu, 26 Nov 2009 12:24:38 Z2009-11-26T15:53:37Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/f5f4f6c4-2744-4966-9fc8-8021f900968chttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/f5f4f6c4-2744-4966-9fc8-8021f900968cGameboyHippohttp://social.msdn.microsoft.com/Profile/en-US/?user=GameboyHippoRegex SearchesI'm trying to take some delphi code and convert it over to C# to test something.  So I copied all of the code and made some search and replaces.  Eventually I get to the point it looks like this.<br/> <br/> myObj.myProperty(StrToInt(myQuery.FieldByName('MY_FIELD').Text));<br/> <br/> Now I have about 50 lines that look like that.  Okay simple!  I'll use a regular expression, right?  So the first thing I want to do is to change it so that it looks like this:<br/> <br/> myObj.myProperty = StrToInt(myQuery.FieldByName('MY_FIELD').Text));<br/> <br/> (Now for those just skimming, I'm making incremental steps to go from Delphi to C#.  So yes, I know that it's not correct at that phase.)<br/> <br/> Easy,  I'll use the expression &quot;(\.\w+)\(&quot; and replace it with &quot;\1 = &quot;.  But then I try it and the IDE says it can't find (\.\w+)\(  Huh?  So I test out (\.\w+) and it finds it.  Okay, so I fire up everyone's favorite regex site regexlib.com  I pasted my regex and my code and it works exactly the way I would expect on regexlib.  This isn't the first time I've struggled with regex searches with Visual Studio (one time it worked however I could only see \0 and not \1).  So is it just broke?  Or am I truly doing something wrong?Sun, 22 Nov 2009 21:51:30 Z2009-11-25T23:35:15Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/8d448520-7b91-4b58-94f4-7e79b88389cchttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/8d448520-7b91-4b58-94f4-7e79b88389ccsky789http://social.msdn.microsoft.com/Profile/en-US/?user=sky789Regular expression: String start with <div> end with <br /> or </div> which ever comes first<p>Regular expression is hard. Can anyone help me with this one?</p> <p>I need to get XYZ 123 and abc 134</p> <p>from this html code below:</p> <p>&lt;html&gt;</p> <p>&lt;div&gt;XYZ 123&lt;br /&gt;</p> <p>&lt;div&gt;abc 134&lt;/div&gt;</p> <p>&lt;/html&gt;</p> <p> Thank you in advance!</p> <p><a href="http://regexlib.com/RETester.aspx"></a></p>Fri, 20 Nov 2009 17:02:29 Z2009-11-26T06:23:23Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/8cefc911-e1dd-486e-aab1-e5835f417a39http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/8cefc911-e1dd-486e-aab1-e5835f417a39NastyBastardhttp://social.msdn.microsoft.com/Profile/en-US/?user=NastyBastardHow to: Verify That Strings Are in Valid E-Mail FormatThis is HALF answered in the MSDN library with an example function called IsValidEmail.<br/> <br/> Does anyone else think maybe it's time the example function (which developers are likely to copy-paste) was changed to closer represented what an email address can actually be?<br/> <br/> Sure, it matches joe.blogs@example.com, or joe-blogs@example.com...<br/> <br/> But how about joe.blogs+work@example.com, or joe.blogs+support@example.com, or e=mc^2@example.com, or many other valid email addresses?<br/> <br/> The page http://msdn.microsoft.com/en-us/library/01escwtf.aspx has been updated for each new release of VisualStudio/.NET, but even the VS 2010/.NET4.0 one isn't much better!Thu, 28 May 2009 22:39:54 Z2009-11-23T19:56:29Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/d7c9d9fe-0cc6-4578-832a-a1124571cd66http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/d7c9d9fe-0cc6-4578-832a-a1124571cd66MAbshirhttp://social.msdn.microsoft.com/Profile/en-US/?user=MAbshirMatch Values inside Tags as<p>Hi Folks,<br/>I played with this for hours and can't seem to get it.<br/>I need Regular Expression pattern that gets the values <a href="mailto:1234569@XYZ2">1234569@XYZ2</a> like following</p> <p><br/>&lt;BookID id=&quot;<a href="mailto:1234569@XYZ2">1234569@XYZ2</a>&quot; Duplicateid=&quot;<a href="mailto:1234569@XYZ2">1234569@XYZ2</a>&quot;&gt;</p> <p>&lt;name&gt;XYZ bla bla&lt;/name&gt;</p> <p>&lt;/BookID&gt;<br/><br/>Just need the pattern string.<br/>Thanks</p>Tue, 27 Oct 2009 14:23:53 Z2009-11-23T16:04:36Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/07ebcb1f-ccd5-4917-937c-542a4404077chttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/07ebcb1f-ccd5-4917-937c-542a4404077cCleyton Jordanhttp://social.msdn.microsoft.com/Profile/en-US/?user=Cleyton%20JordanRegular Expression GroupingHi,<br/> <br/> I am reading about Regular Expression and groupings to figure out how it all works but I am struggling to understand how the group bit works.<br/> <br/> 1 - I would appreciate if someone could help to understand how the group works on the Regular expression below. Why do I need it?<br/> <br/> 2 - I know the the &quot;?&quot; symbol in regular expression means optional but it seems that it is starting a group. Is my assumption right?<br/> <br/> 3 - What does the \b (boundary) mean practically?  Suppose I have a string like this:<br/> <br/> Lenght: 28 <br/> <br/> &quot;This is a big string of text&quot; <br/> <br/> But I allow only a length of 27. So it means the last &quot;t&quot; of the word text would not be part of it. <br/> <br/> &quot;This is a big string of tex&quot; <br/> <br/> So if I use \b, would that remove the whole &quot;text&quot; word from the string?<br/> <br/> <br/> Cheers<br/> <br/> C<br/> <br/> Patterns<br/> -------------<br/> <br/>  return Regex.Match(_textToParse, @&quot;Comment\s:\s(?&lt;comment&gt;.{1,50}\b)&quot;);<br/> <br/> <br/> This patterns is matching the word 'Comment', followed by a single white space, a colon, and a final white space. <br/> <br/> <strong>The next section of the pattern is the bit I do not understand. It uses a named group called comment. </strong> <br/> <br/> Between 1 and 50 characters can be matched. <br/> <br/> <strong>The \b word boundary is used at the end of the pattern to avoid matching partial words.</strong> <br/> <br/>  Fri, 20 Nov 2009 14:48:40 Z2009-11-22T19:55:06Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/279ea6db-6435-4ad8-b6a5-b2a3cdddbccbhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/279ea6db-6435-4ad8-b6a5-b2a3cdddbccbJCNEThttp://social.msdn.microsoft.com/Profile/en-US/?user=JCNETfinding strings that start with "(" .. regex match not working<p>The regex in this  Javascript is not working to find strings that start with &quot;(&quot;. Escaping the ( and using chr(40) did not work either. I confirmed strings that match are being sent. And if I change my match to another character like &quot;-&quot; it works.<br/><br/>How do I do this?<br/><br/>if (strTitle.match(&quot;^&quot;+&quot;(&quot;))<br/>{<br/>  alert(&quot;found&quot;);<br/>}<br/><br/><br/>I tried double excaping \\ also.. no luck<br/><br/>Also, how would I remove (somestring) from the front of the string if found? </p>Thu, 19 Nov 2009 12:26:09 Z2009-11-24T11:04:35Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/d886d975-ee42-43a7-acbe-ce90173128efhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/d886d975-ee42-43a7-acbe-ce90173128efSaad Khanhttp://social.msdn.microsoft.com/Profile/en-US/?user=Saad%20KhanHow to make regex for specific needs?Hi, <div>I need to identify some pattern within a string and process accordingly. Each pattern is very much different from the other one. So I am looking to have regex defined for each of them in order to identify which appropriate process should take place. Can anyone please help me how to make regex for requirements given below:<br/>1. A string starts with % and ends with 0D0A, and contains numbers and capital alphabets (no special characters or spaces)</div> <div>2. A string starts with Y and ends with 0D0A, and contains numbers and capital alphabets (no special characters or spaces)</div> <div>3. A string starts with Y and and contains numbers and capital alphabets (no special characters or spaces)</div> <div>4. A string contains numbers and capital alphabets (no special characters or spaces)</div> <div>5. A string contains words OGN, GINI, TRA, STR, UPL, GEO, AF, PS, BC, AO, ATAR, SPKRM, RCS, STK, BA, AGF, $S, T and BND</div>Tue, 17 Nov 2009 19:20:05 Z2009-11-19T14:45:25Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/369ece25-a8ad-4c58-973b-c9cc4e62c893http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/369ece25-a8ad-4c58-973b-c9cc4e62c893JnewBeehttp://social.msdn.microsoft.com/Profile/en-US/?user=JnewBeeSSRS reporting VB script regex helpI have a large text coming out in ssrs report as , it was done intensionally to output something like below.<br/> <br/> Start of the line has the time stamp in long format (the numeric). I want to know if a regex can search for this pattern &quot;<span style="font-family:Arial;font-size:8pt;font-weight:400;font-style:normal;text-decoration:none;color:Black">*{TS:1258427856254}:&quot;</span> and <br/> converts that into a date in (dd/MM/yyyy) format.<br/> <br/> something like <br/> <br/> Dim dt as Date<br/> dt= DateAdd(DateInterval.Second, Math.Abs(duedate / 1000), DateSerial(1970, 1, 1))<br/> Return dt.ToString(&quot;dd/MM/yyyy&quot;)<br/> <br/> The text that comes out in the report has multiple occurrences of this kind of patterns in the same cell, so I need to convert all those matches to dates.<br/> any help is appreicated., thanks<br/> <br/> The actual large text that I was talking about looks like this.<br/> ------------------------------------------------<br/> <div style="font-size:0pt;unicode-bidi:normal;direction:ltr;vertical-align:top"> <div style="overflow-x:hidden;width:62.09mm"> <div style="text-align:left"><span style="font-family:Arial;font-size:8pt;font-weight:400;font-style:normal;text-decoration:none;color:Black">*{TS:1258427856254}: User: Toolkit </span> <br/> <span style="font-family:Arial;font-size:8pt;font-weight:400;font-style:normal;text-decoration:none;color:Black">4380764. Entered comment: fasdf dsf sdfasd fasd asdfds adsfsd fafdas fadsfasdfasdfased. </span></div> <div style="margin-top:10pt;padding-bottom:10pt;text-align:left"><span style="font-family:Arial;font-size:8pt;font-weight:400;font-style:normal;text-decoration:none;color:Black">*{TS:1258567856254}: User: Toolkit Administrator. Id: 4380764. Entered comment: sd fsdf sdf sdfasd faweqw3erwerwe tew5y45ew643 6546g sdfgdsf . </span></div> <div style="padding-bottom:10pt;text-align:left"><span style="font-family:Arial;font-size:8pt;font-weight:400;font-style:normal;text-decoration:none;color:Black">*{TS:1254870925502}: User: Toolkit Administrator. Id: 4380764. Changed status from: - to Not Applicable. Changed state from: Open to Assigned. Entered comment: assdsad. </span></div> </div> </div> ------------------------------------------------Tue, 17 Nov 2009 04:27:52 Z2009-11-19T00:08:17Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/90f7093d-cbb6-463d-bdbd-a08c3c725b2dhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/90f7093d-cbb6-463d-bdbd-a08c3c725b2dWerner Clausenhttp://social.msdn.microsoft.com/Profile/en-US/?user=Werner%20ClausenRegEx maximum length doesnt work for me.Hi,<br/><br/>Using this pattern: &quot;((?&lt;=^|\s)\d+-\d+-.+(?=$|\s)(?&lt;=(?:^|\s)[^\s]{5,16}))&quot; I'm trying to define a string that consists of 3 'sections' of this pattern: &quot;d-d-x&quot; where 'd' can be any positive number and 'x' can be anything (word number whitespace). Also I need the string to be a minimum of 5 chars and a maximum of 16 chars (The entire pattern). <br/><br/>It appears to work except that the maximum length is ignored if I have a long 'x' value, for example &quot;1-1-This text is way way too long&quot;. This should be false but it is true. If the 16 char length is crossed by the digits it validates false (e.g. &quot;1234567-1234567-Test&quot;). <br/><br/>I cant see why it doesnt pick up the 16 char restriction if the 'x' part is too long?<br/><br/>Wed, 28 Oct 2009 10:46:53 Z2009-11-18T20:02:33Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/59b9a6bc-4b38-49a7-b006-176755e1f801http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/59b9a6bc-4b38-49a7-b006-176755e1f801xalnixhttp://social.msdn.microsoft.com/Profile/en-US/?user=xalnixRegex Substraction of Character Set<p style="color:#c80000;font-weight:bold"><em>(Moderator: I have split this post from its original because its an excellent learning tool concerning the set subtraction)</em></p> <p>Do you know what the following pattern does (without running the code)?</p> <pre lang="x-c#">string test = &quot;1234567890&quot;; string pattern = @&quot;[\d-[57]]&quot;; foreach (Match mx in Regex.Matches(test, pattern) Console.WriteLine(&quot;{0}&quot; , mx.Value);</pre> <br/> <p>There are many ways to be &quot;precise&quot;.</p> <p> </p> <hr class=sig> Les Potter, Xalnix Corporation, <a href="http://yacsharpblog.blogspot.com">Yet Another C# Blog</a>Thu, 13 Aug 2009 20:34:36 Z2009-11-19T14:47:08Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/d1116454-58b3-413e-b978-6b7261af8514http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/d1116454-58b3-413e-b978-6b7261af8514ofirepshttp://social.msdn.microsoft.com/Profile/en-US/?user=ofirepsRemoving certain spaces in a text<span style="font-family:'Segoe UI', 'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;font-size:13px;color:#333333;line-height:16px">Hello, <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">In my program, I get an rtf file (which I load through a Rich-TextBox), and need to format it a bit: I need to remove certain spaces, from certain lines.</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">All of those lines are in this format: [*#] or [*] (where * is a character or a string, and # is a number). These tags appear in separate lines, and I need to remove any white space from these lines.</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">I heard there is a way using Regex, but since I've never used it I have no idea how to do so...</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial"><br/></div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">Any idea?</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">Thanks,</div> <div style="font-weight:inherit;font-style:inherit;font-family:inherit;padding:0px;margin:0px;border:0px initial initial">Ofir.</div> </span>Mon, 09 Nov 2009 16:42:29 Z2009-11-17T21:54:36Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/13cd7289-f835-4abf-8c80-947a3bdd8157http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/13cd7289-f835-4abf-8c80-947a3bdd8157Kamran Shahidhttp://social.msdn.microsoft.com/Profile/en-US/?user=Kamran%20Shahidregular expression to accept either 6 or 9 length digits [and ignore leading and trailing spaces]<p>regular expression to accept either 6 or 9 length digits [and ignore leading and trailing spaces]</p> <p>I have made &quot;^(\s*(\d{6})\s*$)&quot; which will do for 6 digits only validation</p> <p>I have tried &quot;^(\s*(\d{6})|(\d{9})\s*$)&quot; for both six or nine digits only validation but it isn't working</p> Please suggest me what is wrong with it<hr class="sig">Kamran Shahid Senior Software Engineer/Analyst (MCP,MCAD,MCSD.NET,MCTS,MCPD.net[web])Sun, 15 Nov 2009 20:07:43 Z2009-11-20T09:11:08Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/9a916e4b-25f4-4ff3-9f0f-68b2119ffbcbhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/9a916e4b-25f4-4ff3-9f0f-68b2119ffbcbTim Hirtlehttp://social.msdn.microsoft.com/Profile/en-US/?user=Tim%20HirtleHow To Exclude an Email Domain using CreateUserWizard?I have a vs 2005 C# asp.net web application project that uses the email address the user types in as an additional login method. It's working fine but I want to exclude a domain from being used. Lets say it's any @yahoo.com email address. I'd like the validator to recognize this and alert the user that the email domain is not allowed. I suspect this may be do-able thru the EmailRegularExpression property of the CreateUserWizard control. I am currently using that property to make sure an email address has the create format as so:<br/><br/><span style="font-size:x-small;color:#ff0000"><span style="font-size:x-small;color:#ff0000"><font size=2 color="#ff0000"><font size=2 color="#ff0000"> <p>EmailRegularExpression</p> </font></font></span><font size=2 color="#ff0000"> <p> </p> </font></span> <p><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">=</span></span><span style="font-size:x-small"> </span><span style="font-size:x-small;color:#0000ff"><span style="font-size:x-small;color:#0000ff">&quot;^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$&quot;<br/><br/>This works for email formatting. ut I'd like to extend this to also refuse the @yahoo.com email domain if a user types that in as part of the email address when they attempt to create a new account.<br/><br/>Does anyone know how to do that?<br/></span></span></p>Sat, 14 Nov 2009 21:27:35 Z2009-11-19T11:19:17Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/6bbaaafc-6a09-4634-8dec-ed5b7abec542http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/6bbaaafc-6a09-4634-8dec-ed5b7abec542Rahul P Nathhttp://social.msdn.microsoft.com/Profile/en-US/?user=Rahul%20P%20NathWhy Regex FailedHi,<br/> When doing a Regular Expression match,if the match fails how to find why the match failed or where(index position) where the match failed.<br/> Say for example <br/> <pre>Match objMatch; objMatch =Regex.Match(&quot;Hello&quot;,&quot;^ello$&quot;);</pre> Here how to get the index of the failed position.<br/> <br/> Thank You<br/> <hr class=sig> Please mark posts as answers/helpful if it answers your query. This would be helpful for others facing the same kind of problemFri, 13 Nov 2009 06:56:20 Z2009-11-14T05:39:04Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/2a4b71b7-2b43-41d1-b6b1-dcc771631c38http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/2a4b71b7-2b43-41d1-b6b1-dcc771631c38Nicoolaihttp://social.msdn.microsoft.com/Profile/en-US/?user=Nicoolaiignore comment linesHi,<br/> I have a pattern made, but i want it to ignore all lines that start with #.<br/> Is it possible to include this in my pattern, so i don't have to code my way around it?<hr class="sig">Nicolai Søndergaard LM Glasfiber A/SFri, 13 Nov 2009 14:33:30 Z2009-11-14T08:30:47Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/0ea74f15-e216-48f8-87e5-9d337fd291cfhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/0ea74f15-e216-48f8-87e5-9d337fd291cfMotarohttp://social.msdn.microsoft.com/Profile/en-US/?user=MotaroWeird resultI check user input string. It:<br/>1) must have length of 16 characters;<br/>2) can contain any digit;<br/>3) must contain letters from A to F (including);<br/>4) can contain digits and letter in any order, i.e. it can contain all digits or all letters or mix of them (in any proportion).<br/><br/>Here's code:<br/><br/> <div style="background-color:white;color:black"> <pre><span style="color:blue">Dim</span> pattern <span style="color:blue">As</span> <span style="color:blue">String</span> = <span style="color:#a31515">&quot;^(?=.*\d)(?=.*[A-F])\w{16}$&quot;</span> <span style="color:blue">If</span> Regex.IsMatch(txtCode.Text, pattern, RegexOptions.IgnoreCase) <span style="color:blue">Then</span> MessageBox.Show(<span style="color:#a31515">&quot;Code is correct!&quot;</span>) <span style="color:blue">Else</span> MessageBox.Show(<span style="color:#a31515">&quot;Code is INcorrect!&quot;</span>) <span style="color:blue">End</span> <span style="color:blue">If</span> </pre> </div> <br/>I inserted into text box &quot;9<strong>G</strong>A95537E1EECA10&quot;. The second character is letter &quot;G&quot;, which can't be matched by look-ahead! However, &quot;Code is correct&quot;! What can be wrong? <hr class=sig> There is no knowledge that is not power.Thu, 12 Nov 2009 09:10:25 Z2009-11-13T06:58:10Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/411f2626-8765-44f2-ba2f-2a47ab893a00http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/411f2626-8765-44f2-ba2f-2a47ab893a00Ciel Bleuhttp://social.msdn.microsoft.com/Profile/en-US/?user=Ciel%20BleuRegEx Request : Get all the <img src=""> tag in a webpage.Hello,<br><br>How do I get all the &lt;img src=&quot; &quot;&gt; tags on a web page. Includes the value of the src. I need to in my C# application. I want to grab a webpage and parse the page to get only all the &lt;img src=&quot;&quot;&gt; tags and put it in an array or in a database. I want to check the &lt;img src='&quot;&gt; tag of two pages and check if they are similar or not. If not, error or prompt will occur.   <br><br>Please help. <br><br>Thanks and more power.<br><br><br>Tue, 13 Mar 2007 02:01:38 Z2009-11-12T21:05:26Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/9ab5338a-5fae-4069-abab-7371d751ddfchttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/9ab5338a-5fae-4069-abab-7371d751ddfctomsmsofthttp://social.msdn.microsoft.com/Profile/en-US/?user=tomsmsoftFind text between two separate words - to parse text from a message<p align=left><font face=Arial size=2>Hi all,</font></p> <p align=left>I am new to regular expressions. </p> <p align=left> </p> <p align=left>The following text has got three sections; - Name, Date, and Message</p> <p align=left> </p> <p align=left>[Sender]: John Smith  [Received]: 2005-8-21 3:28:9Hi bob, thanks for the message[Sender]: Paul Stein  [Received]: 2005-8-21 3:17:38Cannot make that time...[Sender]: Sarah S  [Received]: 2005-8-20 15:18:2No way! Let me know if it's on. I would love to see that film. It got great reviews.[Sender]: John Smith  [Received]: 2005-8-21 3:28:9Hi bob, thanks for the message[Sender]: Paul Stein  [Received]: 2005-8-21 3:17:38Cannot make that time...[Sender]: Sarah S  [Received]: 2005-8-20 15:18:2No way! Let me know if it's on.</p> <p align=left> </p> <p align=left>I want to extract each of them. </p> <p align=left> </p> <p align=left>The text between &quot;[Sender]:&quot; and  &quot;[Received]:&quot; is the NAME</p> <p align=left> </p> <p align=left>The next word after the  &quot;[Received]:&quot;  is the DATE</p> <p align=left> </p> <p align=left>The MESSAGE starts after the digits of the Date end and it is upto the mark  &quot;[Sender]:&quot; </p> <p align=left> </p> <p align=left>Can anyone tell me how to extract it using C# Regular expressions.</p> <p align=left> </p> <p align=left>Thank you for your time.</p> <p align=left> </p> <p align=left>Tomy</p>Sat, 12 Apr 2008 02:05:04 Z2009-11-12T18:42:37Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/bd2c5c1f-c8f6-49e5-9d71-dc1ee7e8f071http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/bd2c5c1f-c8f6-49e5-9d71-dc1ee7e8f071Rajendra Dewanihttp://social.msdn.microsoft.com/Profile/en-US/?user=Rajendra%20DewaniHow to check for space in a password regex having multiple conditionHi<br/>I have a requirment where in the password field should accept all keys except space, it should have atleast one number , length should be 6 to 50<br/>I tried following but did not work<br/>1) Regex = @&quot;^.*(?=.{6,50})(?=.*\d)(?=.*[a-zA-Z]).*$&quot;<br/><br/>2) ^(?=[^\s])(?=[^\s]{6,50})(?=[^\s]*\d)(?=[^\s]*[a-zA-Z]).*$<br/><br/>Following are my test input text ( test case no 2 is having space at end)<br/><br/> ShouldNOT654321-1<br/>ShouldNOT654321-2 <br/>Should654321-3<br/>ShouldNOT 654321-4<br/>Should NOT654321-5<br/>S houldNOT654321-6<br/>ShouldNOT65432 1-7<br/>S houldNOT 654321-9<br/>Should654321<br/>1Should654321<br/><br/>Please help.<br/><br/>Thanks in Advance.<br/>Rajendra Dewani<br/><br/><hr class="sig">Regards Rajendra DewaniFri, 06 Nov 2009 15:25:46 Z2009-11-18T06:18:20Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/c86c5344-30d2-4997-a1eb-cbdaf72c0c03http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/c86c5344-30d2-4997-a1eb-cbdaf72c0c03co coehttp://social.msdn.microsoft.com/Profile/en-US/?user=co%20coeHow to read string end with question mark in regular expression?Hello,<br/> <br/> I'm facing problem when I read string which is ended by question mark.<br/> I use in my code as the following.<br/> \&quot;?(?&lt;myfield&gt;[^\&quot;]?.*[^\&quot;?]?)\&quot;?<br/> <br/> If string is ended by question mark, it's not working.<br/> Please help me to solve my problem.<br/> Thanks.<br/> <br/> Co CoeMon, 02 Nov 2009 06:00:21 Z2009-11-12T06:25:10Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/e7b76655-c9f2-412d-8834-0f8e05f0400fhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/e7b76655-c9f2-412d-8834-0f8e05f0400fWerner Clausenhttp://social.msdn.microsoft.com/Profile/en-US/?user=Werner%20ClausenHow can I make a match "stop" - please see exampleHi,<br/><br/>I have the following text: &quot;Car[@Id=1]/Engine[@Type=hemi]/@Color&quot;. Now I want to find the @Id value &quot;1&quot;. This is the regex I got so far:  <br/> <pre lang=x-cpp>Car\[@Id=(?&lt;GroupTocapture&gt;.*)\]</pre> However this selects this &quot;1]/Engine[@Type=hemi]&quot;  -  but I want just &quot;1&quot;. Somehow I have to &quot;stop&quot; the regex at the first occurrence of &quot;]&quot;. How to do this?<br/>Mon, 09 Nov 2009 13:18:29 Z2009-11-10T16:29:39Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/83de79c5-45f8-494f-8dab-c69435883b55http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/83de79c5-45f8-494f-8dab-c69435883b55DigitalMafiaProhttp://social.msdn.microsoft.com/Profile/en-US/?user=DigitalMafiaProTrying to prevent a match if string contains XI'm relatively new to RegEx and trying to wrap my head around the whole thing. I'm sure others would need to accomplish what I'm trying, but I can't seem to use the right search terms to find anything. <div><br/></div> <div>I'm using a RegEx to either Match or Not Match if the string contains certain words/characters.</div> <div><br/></div> <div>Example1:  &quot;Do Not Match&quot; vs &quot;Match&quot;</div> <div><br/></div> <div>I want to match each string on the word Match. However, since the first string contains &quot;Do Not&quot; I don't want to match on it at all.</div> <div><br/></div> <div><br/></div> <div>Example2:  &quot;Some Example [Text]&quot; vs &quot;Some Example Text&quot;</div> <div><br/></div> <div>Since the first string contains [] I do not want a match at all.</div> <div><br/></div> <div>Hopefully I've got my point across. I've tried numerous things and all have failed. Conditionals, LookAheads, LookBehinds, etc. I don't know enough to make this thing work the way I want. I will appreciate any assistance.</div> <div><br/></div> <div>Thanks!</div> <div><br/></div>Mon, 09 Nov 2009 19:03:06 Z2009-11-09T23:19:19Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/9b97011f-9d3d-4bec-9628-ddd0fce06cdbhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/9b97011f-9d3d-4bec-9628-ddd0fce06cdbsky789http://social.msdn.microsoft.com/Profile/en-US/?user=sky789Get string starting with XYZ ending ABC<br/>Regular expression is hard. I still cannot get this to work. Please help. Thanks a lot. <p>I need to get string start with</p> <p>        &lt;div class=&quot;divSection&quot;&gt;</p> <p>end with</p> <p>        &lt;img src='/images/books.gif'</p> <p>For example:</p> <p>I need to get</p> <p>          &lt;div class=&quot;divSection&quot;&gt;</p> <p>           &lt;a href=&quot;http://www.zyz.com/sdfd5454_(4545).html&quot;&gt;</p> <p>          &lt;img src='/images/books.gif'</p> <p>From html below</p> <p>&lt;div class=&quot;divSection&quot;&gt;</p> <p>&lt;a href=&quot;http://www.xyz.com/sdfd5454_(4545).html&quot;&gt;</p> <p>&lt;img src='/images/books.gif' alt='books' /&gt;</p> <p>&lt;/div&gt;</p> <p>&lt;div&gt;.....&lt;/div&gt;</p> <p>I have tried this Regular Expression. doesn't work.</p> <p>&lt;div class=\&quot;searchHeadline\&quot;\&gt;\w*&lt;img src='/images/books.gif'</p>Fri, 06 Nov 2009 16:19:46 Z2009-11-09T16:55:02Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/72653560-065c-4135-9d6f-c3591fdfece0http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/72653560-065c-4135-9d6f-c3591fdfece0Werner Clausenhttp://social.msdn.microsoft.com/Profile/en-US/?user=Werner%20ClausenNeed to find a word in a string - but the string contains '[]' so I'm stuck.Hi,<br/><br/>Suppose I have this string = &quot;Car[@type=racecar]/Racecar&quot;. The type (here &quot;racecar&quot;) is what I want to find. It could be any value. How to do that? It seems that whatever I try it doesnt work as the special characters &quot;[&quot; and &quot;]&quot; are part of the text. <br/><br/>Can anyone create RegEx that I can feed as constructor for the RegEx class? Mon, 09 Nov 2009 11:19:41 Z2009-11-09T15:04:56Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/25452dfe-064f-4adc-9609-c41da7d8a581http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/25452dfe-064f-4adc-9609-c41da7d8a581Ralf_from_Europehttp://social.msdn.microsoft.com/Profile/en-US/?user=Ralf_from_EuropeFind all matches with different capitalizationAs the title says, I'd like to find all spellings of a word with different capitalization except one permitted one.<br/><br/>For example 'Label' is fine and the only permitted way. It should not return a match if found.<br/>I'd like to get matches for all 'label' or 'LABEL' (these two are by far the most common) but also 'lAbEl' or 'labeL' (the data entry people here are creative...)<br/><br/>How could a RegEx do that?<br/><br/>I was thinking of l[aA][bB][eE][lL], but that still does not catch anything starting with 'L', like 'LABEL'.<br/>If I include the 'L' it will catch the only permitted style 'Label' again which I do not want find...<br/><br/>Any clue? This looks like a common problem but I could not find a good example yet.Fri, 06 Nov 2009 10:56:18 Z2009-11-09T07:41:09Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/5217c5fa-59f5-42a1-b778-dbde57545401http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/5217c5fa-59f5-42a1-b778-dbde57545401Nano HEhttp://social.msdn.microsoft.com/Profile/en-US/?user=Nano%20HEVisual Studio Auto Shudwon Error...Help.<p><br/>Hi All.<br/><br/>Good day.<br/><br/>When i start my ASP.net project. the IDE could started successfully abut about 8 seconds later. the IDE will closed automatically. Only Close my ASP.net project. the VS won't closed itself totally.<br/><br/>My envronment information. Signatured.<br/><br/><br/>Thanks in advance.<br/><br/><strong>Event Viewer Error Inforamtion.</strong><br/><br/>Faulting application devenv.exe, version 8.0.50727.42, stamp 4333e699, faulting module vcpkg.dll, version 8.0.50727.42, stamp 4333d4c7, debug? 0, fault address 0x0009d134.</p> <p>For more information, see Help and Support Center at <a href="http://go.microsoft.com/fwlink/events.asp">http://go.microsoft.com/fwlink/events.asp</a>.</p><hr class="sig">// Newbie with OS: Windows XP Pro SP3 IDE: VS2005 Pro &amp; .NET: V2.0 and V3.0.V3.5 installed too.Mon, 02 Nov 2009 02:17:36 Z2009-11-08T03:54:58Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/4fcacc55-7bb1-40fe-bcb7-436c5195edd7http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/4fcacc55-7bb1-40fe-bcb7-436c5195edd7xs8899http://social.msdn.microsoft.com/Profile/en-US/?user=xs8899How do I look for all the alert and confirm prompts in a given web page using Regular Expressions?I need to look for all the alert and confirm prompts i a given web page.<br/><br/>How do I do that using Regular Expressions?<br/><br/>Currently I am using <span style="color:#a31515;font-size:x-small"><span style="color:#a31515;font-size:x-small"> <p>alert\\(.*\\)|confirm\\(.*\\)<br/><br/>It works fine if the alert and confirm are on different lines.<br/>However it will return only the alert prompt if they are on the same line.<br/>e.g. alert('Hello World');confirm('Yes?');</p> <p>What am I doing wrong? Please advice. Thanks!!</p> </span></span>Fri, 06 Nov 2009 09:02:18 Z2009-11-07T01:10:04Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/fc30c201-2461-4dcf-9867-46531f625da2http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/fc30c201-2461-4dcf-9867-46531f625da2srinathnshttp://social.msdn.microsoft.com/Profile/en-US/?user=srinathnsvalidating an Email ID?<p align=left><font face=Arial size=2></font> </p>how to validate an email id using general coding in visual C#. pls can any one help me... <img alt=Sad src="http://forums.microsoft.com/MSDN/emoticons/emotion-6.gif">Tue, 21 Aug 2007 06:56:55 Z2009-11-06T15:46:55Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/a7ca6525-063c-43a6-b983-7e42b2428a4dhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/a7ca6525-063c-43a6-b983-7e42b2428a4dLeandro Rodrigueshttp://social.msdn.microsoft.com/Profile/en-US/?user=Leandro%20RodriguesValidatiom email<p>Someone know where hava a example og validation of email. </p> <p><font face=Verdana>Thank you! </font></p>Thu, 24 Aug 2006 12:04:09 Z2009-11-06T15:42:12Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/06fead4d-3725-4172-aa1a-08f594431a04http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/06fead4d-3725-4172-aa1a-08f594431a04waterdinghttp://social.msdn.microsoft.com/Profile/en-US/?user=waterdingEmail address regular expressionI used the function below to validate email addresses.<br/> <br/> // Function to test for valid email address.<br/>         public static bool IsValidEmailAddress(String emailAddress)<br/>         {<br/>             Regex regex = new Regex(@&quot;^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$&quot;);<br/>             Match match = regex.Match(emailAddress);<br/>             return match.Success;<br/>         }<br/> <br/> This regular expression works for amy.charles@test.com, but not robert.o'neil@test.com.<br/> <br/> Can anyone help me to modify the regulation expression, making it to valid for robert.o'neil@test.com <br/> <br/> Thanks in advance!<br/>Tue, 15 Sep 2009 14:13:16 Z2009-11-06T15:40:53Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/07b08444-a569-4e9d-bcc0-bfb87d9de919http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/07b08444-a569-4e9d-bcc0-bfb87d9de919Divakar_ibpmhttp://social.msdn.microsoft.com/Profile/en-US/?user=Divakar_ibpmEmail-Validation using C#.net<p align=left><font face=Arial size=2></font> </p> <p>Hi Friends,</p> <p align=left> </p> <p align=left>               How to validate an Such an Email-id : <a title="mailto:test.test-test@test-med.com" href="mailto:test.test-test@test-med.com">test.test-test@test-med.com</a> [One of my customer having such an mail-id]</p> <p align=left>               Im validating using regular expression  in C#.net:</p> <p align=left>                <font color="#0000ff" size=2></p> <p>               <font color="#0000ff" size=2></p> <p>string</font><font color="#000000" size=2> pattern = </font><font color="#a31515" size=2>@&quot;^[a-z][a-z|0-9|]*([_][a-z|0-9]+)*([.][a-z|&quot;</font><font size=2><font color="#000000"> +</font></p> <p></font><font color="#a31515" size=2>@&quot;0-9]+([_][a-z|0-9]+)*)?@[a-z][a-z|0-9|]*([-][a-z|0-9]+)*\.([a-z]&quot;</font><font size=2> +</p> <p></font><font color="#a31515" size=2>@&quot;[a-z|0-9]*(\.[a-z][a-z|0-9]*)?)$&quot;</font><font size=2>;</font></p> <p align=left><font size=2></font> </p> <p align=left><font size=2> <font size=2></p> <p>System.Text.RegularExpressions.</font><font color="#2b91af" size=2>Match</font><font size=2> match = System.Text.RegularExpressions.</font><font color="#2b91af" size=2>Regex</font><font size=2>.Match(editemail.Text.Trim(), pattern, System.Text.RegularExpressions.</font><font color="#2b91af" size=2>RegexOptions</font><font size=2>.IgnoreCase);</p> <p></font><font color="#0000ff" size=2>if</font><font size=2> (!match.Success)</p> <p>{</p> <p></font><font color="#2b91af" size=2>MessageBox</font><font size=2>.Show(</font><font color="#a31515" size=2>&quot;You must specify valid E-mail&quot;</font><font size=2>, </font><font color="#0000ff" size=2>this</font><font size=2>.vGlobalVariables.gProductVersion, </font><font color="#2b91af" size=2>MessageBoxButtons</font><font size=2>.OK, </font><font color="#2b91af" size=2>MessageBoxIcon</font><font size=2>.Warning);</p> <p></font><font color="#0000ff" size=2>this</font><font size=2>.editemail.Focus();</font></p> <p align=left><font size=2>}</font></p> <p align=left><font size=2></font> </p> <p align=left><font size=2>While using the above code its saying You must specify valid email.</font></p> <p align=left><font size=2>How to validate the above email-id [test.test-test@test-med.com]?</font></p> <p align=left><font size=2></font> </p> <p align=left> </p> <p align=left>Thanks</p> <p align=left>Divakar</p> <p align=left><font size=2></font> </p> <p align=left><font size=2> </p></font></font></font><font size=2></font>Wed, 30 Apr 2008 13:39:51 Z2009-11-06T15:39:22Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/947656d4-b5c9-4ea9-b335-f78e681dcb28http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/947656d4-b5c9-4ea9-b335-f78e681dcb28BitFlipperhttp://social.msdn.microsoft.com/Profile/en-US/?user=BitFlipperProblems escaping some characters<p>Hi,<br/><br/>I have an app where the user types in text into a textbox. This is used to filter the contents of a list using the RegEx class. The user can choose filter options like &quot;Contains&quot;, &quot;Starts With&quot;, &quot;Ends With&quot;, etc. As far as the user is concerned, the text they type is <strong>not</strong> used as regular expressions, but just simple text (so they are not supposed to type in regular expressions themselves).<br/><br/>For instance, my regular expression filter for &quot;Contains&quot; looks like this:<br/><br/>(s){1,}<br/><br/>Where &quot;s&quot; is the text that the user typed in, for example:<br/><br/>string regexText = &quot;(&quot; + textBox.Text + &quot;){1,}&quot;;<br/><br/>It all works great except when the user types in some characters, like &quot;:'. So the regex expression will be &quot;(:){1,}&quot;. In this case it refuses to match any text that contains a &quot;:&quot;. I tried these variations, but nothing works:<br/><br/> &quot;(:){1,}&quot;  <br/> &quot;(<a>\\:){1</a>,}&quot;<br/> &quot;(<a>\\\\:){1</a>,}&quot;<br/> &quot;(<a>\\x3a:){1</a>,}&quot;<br/> @&quot;((<a>\:){1</a>,}&quot;<br/> @&quot;((<a>\\:){1</a>,}&quot;<br/><br/>I also used RegEx.Escape(textBox.Text) but it doesn't do any escaping for &quot;:&quot;.<br/><br/>But nothing causes it to match anything that contains a &quot;:&quot;. Is there a way to easily escape a whole string, so that it doesn't matter what the user types in?<br/><br/>On a slightly similar note, why does the following not match &quot;(&quot;...<br/><br/> &quot;(\\(){1,}&quot;<br/><br/>...but...<br/><br/>  &quot;(<a>\\x28){1</a>,}&quot;<br/><br/>...does?<br/><br/>Any ideas?</p>Thu, 05 Nov 2009 22:21:41 Z2009-11-06T01:44:40Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/f8dbeeb5-4cb8-4a87-b74f-91fc821760a7http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/f8dbeeb5-4cb8-4a87-b74f-91fc821760a7tommyolesenhttp://social.msdn.microsoft.com/Profile/en-US/?user=tommyolesenHow to find misspelled words with regexHi all<br/> <br/> I need a RegEx that will find a specific word within a long string. The issue is that this word may be misspelled and I need to find it even so. I would like to accept a certain percentage of wrong-ness when looking for the word. Ex.<br/> <br/> The complete string: Hello, this is my <strong>comp/et </strong> string to look at<br/> The word to search for: complete<br/> <br/> Let’s say that I which to accept a maximum of two wrong letters in the above string, then the RegEx should match the word complete. However, if I only accept 1 wrong letter it shouldn’t find it. Ideally the RegEx would also be able to handle whitespaces, and missing letters. Ex:<br/> <br/> The complete string: Hello, this is my <strong>com plee </strong> string to look at<br/> The word to search for: <strong>complete</strong> <br/> <br/> This should match the word as well, even though there is a whitespace between ‘m’ and ‘p’ and the letter ‘l’ is missing. Is this possible at all with RegEx or should I be looking at an alternative way to solve it?<br/> <br/> Thanks, TommyThu, 05 Nov 2009 11:14:38 Z2009-11-11T10:05:16Zhttp://social.msdn.microsoft.com/Forums/en-US/regexp/thread/2ef10c8f-1d80-4755-af80-cc825b1ecaf7http://social.msdn.microsoft.com/Forums/en-US/regexp/thread/2ef10c8f-1d80-4755-af80-cc825b1ecaf7Pilot_http://social.msdn.microsoft.com/Profile/en-US/?user=Pilot_Match whole numbersWhat could be the regular expression to replace whole numbers in a textfile? <br/><br/>For example<br/><br/>I want to replace 7 with 7.59 but not 167 with 167.59 <br/><br/>Any ideas?Wed, 04 Nov 2009 17:15:29 Z2009-11-04T21:18:37Z