.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

regex: How to allow a comma?

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :ASP.Net
Hi,How to allow a comma?"^ \ $? (\ D (1.3),? (\ D (3 },?)* \ d (3) (\. \ D (0.2))? | \ D (1.3) (\. \ d (0.2))? | \. \ d (1.2 }?)$"  This is works, I need character ","Helpthanks

View Complete Post

More Related Resource Links

Comma-Delimited Output

One of the common tasks performed when retrieving data from a SQL Server database is returning the result as a comma-delimited output instead of a result set. This task can be performed by using a CURSOR selecting the column to be concatenated together. Each row returned by the CURSOR is then concatenated together into a variable separating each one by a comma.

Regex pattern for validating IPv6


Can anyone can make a regular expression pattern for validating IPv6 (not IPv4)?

Ipv6 has many formats and aliases. I tried making the pattern but written in a lot of codes (i'm not sure my code below will be 100% accepting valid formats and 100% declines invalid formats).


Regex.replace [h2] to


I try to replace [h2] to <h2>
I use this coding:

string o = "<h2>test</h2>";
o = Regex.Replace(o, "[h2]", "<h2>");
o = Regex.Replace(o, "[/h2]", "</h2>");


But the result after the first regex is:


So that is not what i want.
After the first 1, he should make:


Whats wrong?

multi-line regex in C#

Hi, I am sure this is really simple, but i can't figure it out. I have a string that looks like this: REV=A1 STATUS=Working I would like to grab 'A1' and 'Working', in a single regex, but i cannot seem to handle the linebreak. I have tried putting something together in Rad's Regular expressions designer and this pattern will match it all: REV=(?<Rev>.{2}) STATUS=(?<Status>.+) but i don't know to write a two-lined regex in C#. I have also tried to include the linebreak, with both \n and \r, but none of them worked. So, how is my pattern suppoed to look for this?Nicolai Søndergaard LM Glasfiber A/S

Regular Expression for Digits, comma & space combination

Hi Can you suggest a Regular Expression for the following category. A text box which should contain: Max size : 53 0-9 digits + a comma + a space The 0-9 numbers should be repeated 5 times and separated by a comma and a space Eg: 123456789, 123456789, 123456789, 123456789, 123456789 Thanks, David.      

I need a regex for the following sentence

I have a line of text which is as follows  : This should occur before variable1 = 1 variable2 =2 variable3=6 variable4=9   I want a regex which checks if this text (This should occur before ) comes before  the string of the variables (variable1, variable2, variable3, variable4 ) and also  should pass if the placement of the variables can occur anywhere in the sentence.Also the regex should pass only if the variable4 has a value greater than 9.  

Regex for checking number greater than 9

Hi All , I need to write a regex which can check for a number greater than equal to 9 .  

Exclude a word regex

Currently i am using one regex for accepting some records from a file.  That regex is ^[a-zA-Z0-9| ].*$. This regex accepts record starting with alphanumerics or blank space.I want to modify this regex such that, previous conditions should be there and regex should not accept record starting with word 'bbb'. Which regex should be used?

Need RegEx for four decimal place

Hello All, I have total 19 digits in which i have 4 decimal place. What would be the pattern. ThanksBizTalk Beginner

Formating Text using Regex

Hello Everyone,   I have extracted some text from HTML pages & writing it to a Text file. Text is scrambled everywhere in the file after saving.   in the output text there some new line , tabs etc ... is there any way to remove them ? using Regex ?? text i am getting after extraction :- ( checked using Debug ) Pradeep \r\n\t\t\t\t\t\t\t    \r\n\t\t\t\t\t\t      G\r\n                               \r\n                                 \r\n                                \r\n                                State College \r\n                                 \r\n 

Split string using Regex with escape sequences

What is the regex to split a string using the delimiter ';', but not split on '\;' ? Backslash would be my escape character in my split string, so finding '\;' would not split, but '\\;' would split. For example I want a regex that would split the following:     "aaa;bb;cccc\;dd\;eee\\;ff\\;ggg\\\;hhh" into the following string array:     aaa     bb     ccc\;dd\;eee\\     ff\\     ggg\\\;hhh   Thanks!   -Sylvain

Best regex for email body on contact form?

I'm not sure the best way to do a regex for the body section of an email contact form.  I want to use the regex to prevent more than 150 characters from being entered.  I assume this is sufficient, I may need more.  I also want it to help guard against sql injection attacks. The more I think about it the more characters I can think of that should be allowed.  I want to allow punctuation since it's for an email and people should be using full sentences.  These are some other things that make sense to allow: " , ', : , ; , $ , . , ! , ? , - , _ , @ , & , ( , ). They cover situations when someone may put an email address or phone number in the body section for the email.  I also want to allow letters and numbers.    I'm not sure if it's best to allow the characters I mentioned or not allow characters that pose a potential threat.  I think allowing the ones I want is the best way, but I'm not sure.  Can someone please give an example and/or suggestions?  Are there other characters that should be allowed?  I don't have much yet: "^(?i)[a-z0-9\s]{1,150}$"

REGEX does not match when line ends with the characters.. also, how to negate words that contain the

\S*(ai|ie)\S*   seems to match all words with characters ai and ie in them.  However it does not match if the line ends with them, how can fix that?Also, how can I match all words that DO NOT contain those characters.. I've tried ?! and [^ to no avail.Thanks in advance for any help or information!

How to find misspelled words with regex

Hi all 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. The complete string: Hello, this is my comp/et string to look at The word to search for: complete 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: The complete string: Hello, this is my com plee string to look at The word to search for: complete 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? Thanks, Tommy

RegEx, XSD and Dataset not working together?

i have a XSD file that includes that includes the simple types     <xs:simpleType name="PhoneNo">         <xs:restriction base="xs:string">             <xs:pattern value="0(1|2|3|7)\d+" />             <xs:maxLength value="11" />             <xs:minLength value="10" />         </xs:restriction>     </xs:simpleType>     <xs:simpleType name="Email">         <xs:restriction base="xs:string">             <xs:pattern value=".+@.+\.\w+" />         </xs:restriction>     </xs:simpleType> and the element      <xs:element name="Input" msdata:IsDataSet="true" msdata:Locale="en-GB">         <xs:complexType>             <xs:choice minOccurs="1" maxOccur

RegEx Request - Extract an tag from string...

Hello, Can anyone give me a regular expression that will extract the <img> tag from a string.  I am receiving descriptions from an rss feed and the description contains an <img> tag in the text.  I want to extract the <img> so that I can display it in a different location on my page. I have fooled with some regular expressions, but my knowledge of them is not very good. Thanks in advance for any help!!

.Net Regex Resources Reference

For those starting out with Regex'es or even those who are old hands here are some resources to help. .NET Framework Developer's Guide .NET Framework Regular Expressions Regular Expression Language Elements Character Classes such as. \d \s [ ] defined. Quantifiers such as+ * ? { } Options such asMultiline Compiled SingleLine Expression Classes such as Regex Match MatchCollection GroupCollection Regular Expression Examples Tutorials 30 Minute Regex Tutorial on CodeProject. .Net Coders Regex Overview breaks down groups and matches in one of the best overviews of the topics. Introduction to Regular Expressions on CodeProject. Understanding Basic Regular Expression Syntax (Section 3.10.) in the CodeProject's book chapter previewMicrosoft Visual C# .NET 2003 Developer's Cookbook . Its a preview of Chapter 3: Strings and Regular Expressions. Eric Gunnerson's Regex 101 . A listing of differing match topics. Great for a beginner to look at after acquiring the basics of Regex, many examples. How to: Search Strings Using Regular Expressions (C# Programming Guide) in MSDN Library. Topics General Regular Expressions and the If Conditional on OmegaCoder's blog. Want faster regular expressions? Maybe you should think about that IgnoreCase option... (Compilation) For an overview of the three different modes,interpreted, on-the-fly comp
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