Click here to Skip to main content
14,975,862 members
Everything / General Programming / Regular Expressions

Regular Expressions

regular-expression

Great Reads

by Christoph Buenger
Describes PHP application development with the free Scavix Web Development Framework (Scavix-WDF).
by honey the codewitch
Build a feature rich, non-backtracking regular expression engine and code generator in C#
by Daniel Vaughan
A Visual Studio regex to remove someone's overzealous use of regions in VS. Find and replace: (^.*\#region.*$)|(^.*\#endregion.*$) Remember to enable regular expressions in the Visual Studio find and replace dialog.
by honey the codewitch
A Non-Backtracking Regular Expression Engine for .NET (Core)

Latest Articles

by Ryan S White
A simple drop-in function that provides T4 like template based text generation.
by Marijan Nikic
Regex that can be used for parsing Cron Expressions
by honey the codewitch
Hoodwink your computer into doing your work for you using regular expressions
by siliconvideo
This StringBox control implements keystroke validation using regular expressions and a touch of glue logic

All Articles

Sort by Score

Regular Expressions 

Please Sign up or sign in to vote.
31 Oct 2014
Christoph Buenger
Describes PHP application development with the free Scavix Web Development Framework (Scavix-WDF).
Please Sign up or sign in to vote.
21 Nov 2019
honey the codewitch
Build a feature rich, non-backtracking regular expression engine and code generator in C#
Please Sign up or sign in to vote.
23 Nov 2009
Daniel Vaughan
A Visual Studio regex to remove someone's overzealous use of regions in VS. Find and replace: (^.*\#region.*$)|(^.*\#endregion.*$) Remember to enable regular expressions in the Visual Studio find and replace dialog.
Please Sign up or sign in to vote.
7 May 2010
Chris Trelawny-Ross
I agree it would be nice to be able to use the group name in the switch; unfortunately the Group object doesn't have a Name property (and neither does its base class Capture) so the best you'll be able to do is the following:string ReplaceMatch(Match m) { if...
Please Sign up or sign in to vote.
31 Mar 2019
honey the codewitch
A Non-Backtracking Regular Expression Engine for .NET (Core)
Please Sign up or sign in to vote.
3 May 2010
OriginalGriff
1 alternative  
I am using a Regex with a MatchEvaluator delegate to process a format string, e.g. "Time: %t, bytes: %b" would replace the "%t" with a time stamp, and the "%b" with a bytes count. Needless to say, there are loads of other options!To do this, I use: Regex regex = new...
Please Sign up or sign in to vote.
27 Sep 2019
Mohamed Kalmoua
In this article, I will discuss a WiFi password recovery and management tool that I created in WPF using Visual Studio 2019.
Please Sign up or sign in to vote.
2 Jan 2021
honey the codewitch
Hoodwink your computer into doing your work for you using regular expressions
Please Sign up or sign in to vote.
15 Jun 2012
VJ Reddy
I think the matching with prefix and suffix options of Regex can be used to extract only the required value from the parentheses as shown below:string text = @"STRING[261] Directory(\FTP\OSP_003\)\nSTRING[9] FileName(SysParaI)\nSTRING[4] FileExtension(002)";Match match = Regex.Match(text,...
Please Sign up or sign in to vote.
18 Oct 2011
George Swan
The Regex method uses comma, full stop, hyphen, and apostrophe as word separators. The problem with this is that these characters are not universally used as separators. The hyphen is used to join two words. Could I suggest the following?string input = "Mr O'Brien-Smith arrived at 8.30 and...
Please Sign up or sign in to vote.
5 Jan 2011
Bryian Tan
ASP.NET Password Strength Regular Expression. Customize n numbers of upper case, digits, special characters.
Please Sign up or sign in to vote.
3 Feb 2020
honey the codewitch
A Pike virtual machine and optimizing compiler for regular expressions using an NFA engine
Please Sign up or sign in to vote.
20 Jan 2011
Rob Philpott
OK - this is a bit of algorithmic fun and I'll tell you how I'd go about it, but you'll have to figure the code out yourself.You need to combine a forward reading parser with a recursive object or functional call. On every open tag you need to go one level further of recursion, storing the...
Please Sign up or sign in to vote.
23 Apr 2015
CHill60
Essentially you are attempting to parse the grammar in the string.See this CP article Parsing Expression Grammar Support for C# 3.0 Part 1 - PEG Lib and Parser Generator[^] which is also referenced from this post[^] that includes some alternative ideas.Here's an academic paper[^] on the...
Please Sign up or sign in to vote.
2 May 2016
George Jonsson
You can try thishttp:(?:(?!http:).)*It will match from http: up to the next occurence, but not including it.The result of your sample string will be 3 separate matches.[UPDATE]Forgot the https variant:http(?:s)?:(?:(?!http(?:s)?:).)*
Please Sign up or sign in to vote.
14 Jul 2019
honey the codewitch
Creating a simple parser in 3 easy lessons
Please Sign up or sign in to vote.
1 Feb 2020
honey the codewitch
Add non-backtracking fast DFA regular expression and finite state automata to your projects
Please Sign up or sign in to vote.
19 Dec 2010
PIEBALDconsult
How about loading it into an XmlDocument and getting the InnerText? (Provided the HTML is well-formed XML, of course.)
Please Sign up or sign in to vote.
20 Dec 2010
JHoye
Consider using the open source HTML Agility Pack library (htmlagilitypack.codeplex.com).It lets you use XPATH queries to access very specific parts of an HMTL document, and the HTML does not have to be valid, well-formed XML. In addition to accessing the raw inner text of an element you can...
Please Sign up or sign in to vote.
23 Dec 2010
OriginalGriff
Try([a-zA-z]...
Please Sign up or sign in to vote.
14 Apr 2012
VJ Reddy
One option is to split the original string at the location of ? and reconstruct using @param as shown belowSub Main Dim statement As String = "INSERT INTO X (a,b,c) values (?,?,?)" Dim statements As String() = statement.Split("?"C) 'Construct a stringbuilder Dim sb As New...
Please Sign up or sign in to vote.
15 Jun 2012
Clifford Nelson
You can go simple and justRegex r = new Regex(@"\(.*\)");var e = r.Matches(s);e is a collection of matches, and will include the "()"Will not requerRegex r = new Regex(@"\((.*)\)");var e = r.Match(s);e.Groups will contain all matches, the second item will your result
Please Sign up or sign in to vote.
6 Sep 2012
Volynsky Alex
Regular expression, or often known as regex, is a pattern that consist of rules used to match a certain set of strings. They are extremely powerful, and you’ll need them in most programming languages you come across, especially when there’s a need to scan and match context for further...
Please Sign up or sign in to vote.
6 Sep 2014
Marco Bertschi
A walk-through on how a Key-Value pair can be parsed using a PERL-compatible regex engine
Please Sign up or sign in to vote.
5 Jan 2015
DamithSL
sample code:var splitwords =new string[] {"egg","eggs", "have a receipt"}; string input ="I have a receipt with eggs but others with just one egg";foreach (string word in splitwords){ var regex = new Regex(@"(?
Please Sign up or sign in to vote.
15 Mar 2016
Jochen Arndt
It is returning a length of 350 because the string contains 350 characters.To verify this, select the text and paste it into an Unicode editor (e.g. with Notepad++ choose File - New, Encoding - UCS-2 Little Endian, and paste the text). Within Notepad++, it will look like (shortened, there...
Please Sign up or sign in to vote.
22 Jul 2020
siliconvideo
This StringBox control implements keystroke validation using regular expressions and a touch of glue logic
Please Sign up or sign in to vote.
14 Nov 2010
OriginalGriff
You either have an extra backslash: "[(.*?;)([(if)(while)(for)]\s*?\(.*?\){({.*?})*?})]"becomes"[(.*?;)([(if)(while)(for)]\s*?(.*?\){({.*?})*?})]"or one too few:"[(.*?;)([(if)(while)(for)]\s*?\(.*?\){({.*?}\)*?})]"
Please Sign up or sign in to vote.
11 Jan 2011
#realJSOP
It's certainly the fastest way to type it.If you want to try to find faster ways, be a programmer and try different ways to approach the problem.Performance for such a task would greatly depend on the length of the string involved.
Please Sign up or sign in to vote.
30 Mar 2011
OriginalGriff
Unfortunately, AFAIK there is no way top make a regex which replaces "one of these" with "one of those".You can clean it up a bit, by using a MatchEvaluator to remove the need for a String builder. Make the regex just a list of known invalid characters and: result =...
Please Sign up or sign in to vote.
26 May 2011
Kim Togo
Try this Regex: ,(?!(?
Please Sign up or sign in to vote.
20 Nov 2011
Michel [mjbohn]
This is a so called 'regular expression' (RegEx).Just have a look at this :http://en.wikipedia.org/wiki/Regular_expression[^]Your RegEx will match when:0 or more whitespaces (\s*)are followed byexactly two digits (\d{2})followed by ':'followed by 0 or more whitespaces...
Please Sign up or sign in to vote.
22 Feb 2012
Peter_in_2780
The first thing to do is to write down exactly what you want to match. From your examples, it looks to me like this is a good start:a non-letterfaceoptional apostropheoptional sa non-letterTranslated into a regex, this turns into[^a-zA-Z]face\'?s?[^a-zA-Z]You then need to...
Please Sign up or sign in to vote.
11 Apr 2012
Mehdi Gholam
Use :(?\(\s*\?.*)+Which will give you the (...) portion and then just count the number of ? chars and replace with @paramN where N is an iterator.
Please Sign up or sign in to vote.
16 Apr 2012
Lutosław
Find patterns in a sequence of objects using a familiar language.
Please Sign up or sign in to vote.
20 Jun 2012
Tim Corey
Note: These suggestions aren't Regex specifically, which I know you asked for. I'll work on a RegEx for you as well, but these solutions seem simpler and lighter than full RegEx:Pass the file names into the GetExtension method like so:string extension =...
Please Sign up or sign in to vote.
21 Jun 2012
AspDotNetDev
You want a negative lookahead or a negative lookbehind. Suppose you want to validate so that a phrase starts with "string" and ends with "bee", but does not contain "like". You could use this regular expression (which uses a negative lookahead):(?!.*like)^sting.*bee$The negative look ahead...
Please Sign up or sign in to vote.
12 Sep 2012
Clifford Nelson
Look at the following tip (do not consider it an article, although so classified): Converting Wildcards to Regexes[^]
Please Sign up or sign in to vote.
27 Sep 2012
Yvan Rodrigues
Replace ntext\(\d+\) with TEXTReplace DEFAULT\(\((\d+)\)\) with DEFAULT '$1'
Please Sign up or sign in to vote.
25 Feb 2013
Joezer BH
Hello Choudhary, \w in regex means: any word character (letter, number, underscore)you may use . (dot) that means: any single characterGood luck, Edo
Please Sign up or sign in to vote.
30 Oct 2013
strogg
Try this instead of enclosing your exp with [^\d]...regex...[^\d](?
Please Sign up or sign in to vote.
19 Apr 2014
Peter Leow
Try this:^[a-zA-Z]+(\s[a-zA-Z]+)?$
Please Sign up or sign in to vote.
16 Jun 2014
Peter Leow
^[a-zA-Z][a-zA-Z\s\-]*$
Please Sign up or sign in to vote.
8 Sep 2014
cogi83
A SW to send your WAN IP and other info via email
Please Sign up or sign in to vote.
1 Nov 2014
George Jonsson
Basically you can replace the keyword @city with \s+(?[\S\s]+?)\s+Example:string template1 = @"^Tell me the forcast of\s+(?[\S\s]+?)\s+for\s+(?[\S\s]+)$";In C# you useMatch m = Regex.Match("Tell me the forcast of Las Vegas for tomorrow", template1);if...
Please Sign up or sign in to vote.
10 Nov 2014
PIEBALDconsult
I have been unable to determine what the meaning of \Q is in Java, but in Perl, it's:\Q quote (disable) pattern metacharacters until \E\E end either case modification or quoted section,This doesn't appear in the .net implementation and seems needless in your...
Please Sign up or sign in to vote.
12 Dec 2014
Unihedron
See this regex:/^(?=[^a]*a)(?=[^n]*n)(?=[^u]*u)/iRegex explanation:^ Asserts position at start of string.(?=[^a]*a) Asserts that "a" is present after all the non-"a"s.(?=[^n]*n) Asserts that "n" is present after all the non-"n"s.(?=[^u]*u Asserts that "u" is present after all...
Please Sign up or sign in to vote.
12 Dec 2014
Maciej Los
The same you can achieve using Linq[^] query:string[] words = new string[]{"Anitha", "Nandu","anushka","jayasree"};var qry = from w in words where w.ToLower().Contains('a') && w.ToLower().Contains('n') && w.ToLower().Contains('u') select w;foreach(string word in...
Please Sign up or sign in to vote.
21 Jan 2015
Peter Leow
Try this:^[\d\._\w]+$also read: The 30 Minute Regex Tutorial[^]
Please Sign up or sign in to vote.
12 Feb 2015
Richard Deeming
Two problems with your code:You've used Regex.Match instead of Regex.IsMatch;You've missed the @ prefix on the second "\b" string;I'd also be inclined to add a Regex.Escape around the word to find, in case it contains any special characters.var listTobeDeleted =...
Please Sign up or sign in to vote.
10 Nov 2015
OriginalGriff
Try:$\d{9}[A-Za-z]^
Please Sign up or sign in to vote.
7 Dec 2015
Peter Leow
Try this:(?)\d\.\d\.\d.\d(?=\)The keys lie in:(?
Please Sign up or sign in to vote.
22 Dec 2015
Richard Deeming
Your parameters are the wrong way round - the first parameter is the string to test, and the second parameter is the regular expression to use:Regex.IsMatch(myString, ".* My name is XYZ")To retrieve the details of the match, use the Match method[^], which returns a Match object[^]....
Please Sign up or sign in to vote.
4 Mar 2016
Richard Deeming
Your pattern currently consumes the leading and trailing commas, so every other value is skipped.You need to use zero-width positive lookahead/lookbehind assertions instead:Regular Expression Language - Quick Reference[^]Also, it would be better to use [^\,]* rather than .*?, since you...
Please Sign up or sign in to vote.
2 May 2016
Patrice T
See solution 1 for a working solution.This site can help to see if a regex is doing what you expect.Debuggex: Online visual regex tester. JavaScript, Python, and PCRE.[^]I guess you will have to read regex documentation to understand advanced usages.perlre - perldoc.perl.org[^]By...
Please Sign up or sign in to vote.
1 Jun 2016
OriginalGriff
String.Split isn't a Regex - it's just a basic string method that can't do anything too complex.Try:("[^"]*")|([^\s]+)as a regex - it should give you what you want as separate Group values.
Please Sign up or sign in to vote.
27 Sep 2016
OriginalGriff
It's not a valid regex for a telephone number: what it matches is literally a single numeric digit followed by the text "{5-15}" and nothing else.What they probably meant to say was:^[0-9]{5,15}$Which matches "any string of numeric digits between 5 and 15 characters long,...
Please Sign up or sign in to vote.
25 Sep 2019
MadMyche
Using RegEx for Credit Cards is at best rudimentary; you are better off validating what you are actually working with Credit Card numbers themselves are generally at least 16 digits long; the primary exception being American Express which uses 15 digits. CVV numbers are 3 digits long for most;...
Please Sign up or sign in to vote.
22 Sep 2020
Maciej Los
[EDIT] If you would like optionally to get first occurance of 99,00... For lines: My super data plan 10gb mobile 99,00 1 jul - 31 jul 2020 99,00 My super data plan 10gb mobile 1 jul - 31 jul 2020 99,00 Try this: ...
Please Sign up or sign in to vote.
11 Jun 2018
Member 10481957
Chronological Expressions is a RegEx inspired Pattern Matching Library and Specification for query event logs
Please Sign up or sign in to vote.
9 Sep 2010
Om Prakash Pant
Please check the following modified code:Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress Dim allowedChars As String = "0123456789" If e.KeyChar ControlChars.Back Then If...
Please Sign up or sign in to vote.
5 Jan 2011
MarcoBot
NOTE: If you're really wanting plain text, then you should also be sure to decode the HTML entities (System.Web.HttpUtility.HtmlDecode()) on the resulting text, or you'll wind up with HTML/XML character entity text in your output, such as & and [ If you're going to immediately output the...
Please Sign up or sign in to vote.
8 Feb 2011
Bryian Tan
How to extract the text from a hyperlink and preserve other HTML tags
Please Sign up or sign in to vote.
26 Feb 2011
DaveAuld
In case you have never heard of it, this is an excellent site. Contains cheat sheet and testers. As well as a list of predefined expressions.regexlib[^]That is a suggestion, i will see if i can come up with a solution!Edit: See you posted your question on that site also :doh: I will...
Please Sign up or sign in to vote.
26 Feb 2011
OriginalGriff
I wouldn't use a regex: you could but it would be quite complex and difficult to maintain.Instead, I would sort the characters in my input string, and then check it.If two adjacent characters are the same, fail.If any character is not in the set 'B', 'L', 'R', 'T', failOtherwise, pass.
Please Sign up or sign in to vote.
29 Apr 2011
Manfred Rudolf Bihy
Save yourself the pain and use XPath expressions[^] to dissect your XML.Regular expression are really no good for parsing nested structures.Best Regards,-MRB
Please Sign up or sign in to vote.
6 May 2011
OriginalGriff
Try:public static Regex regex = new Regex("para.*tabs.*", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Compiled);Get a copy of Expresso[^] - it's free,...
Please Sign up or sign in to vote.
30 May 2011
yesotaso
//Get related text blockstring subContent = Regex.Match(content,@"(?
Please Sign up or sign in to vote.
6 Jun 2011
Prerak Patel
1. You can use \d{10} instead of @"\d\d\d\d\d\d\d\d\d\d"2. What is this : expvalidator.IsValid.IsValid?Edit ----Because the default value of this property is true, it will return true if you query this property before validation is performed. For example, this might occur if you attempt...
Please Sign up or sign in to vote.
14 Jun 2011
OriginalGriff
And I think you will continue looking: that is not something I would want to do with a regex, particularly since you do not know the length of the sequence to be checked for.Instead - since I assume this is for checking password strength - why not use existing code: Password Advisor[^] has...
Please Sign up or sign in to vote.
1 Jul 2011
Nyarlatotep
2 alternatives  
Hello, I cannot find a valid regular expression pattern for my needs.I have a sample string like this:I have four child of seven years each, [seven] years ago I had no child, because I was fourteennow, I want match and then substitute the words "four" and "[seven]".So I have...
Please Sign up or sign in to vote.
7 Jul 2011
OriginalGriff
Try:public static Regex regex = new Regex( @"^\(_\d*\)\s*", RegexOptions.IgnoreCase | RegexOptions.Multiline | RegexOptions.CultureInvariant | RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled );string result =...
Please Sign up or sign in to vote.
18 Aug 2011
OriginalGriff
That actually quite difficult, and probably not suited for a regex at all. The problem is that you want to accept the "Peter" from "Peter's" but discard "5th". What you really want to do is probably use a dictionary (a proper one, rather than an .NET Dictionary class) and check for actual words....
Please Sign up or sign in to vote.
25 Sep 2011
André Kraak
You can use the Regex.Split Method[^].Use these links to find out how regular expressions work:.NET Framework Regular Expressions[^]Regular Expression Language Elements[^]
Please Sign up or sign in to vote.
17 Oct 2011
NewPast
Dim pattern="http.*\.flv"Dim pattern2="^http.*\.flv$"'^ means at the 1st of the line; $ means at the end of the line
Please Sign up or sign in to vote.
25 Oct 2011
Jacobs76
I also use a Regex expression to count words, which returns the same number of words as MS Word. I wrap the Regular Expression in a String extension method to make it easy to use.public static class StringExtensions{ /// /// WordCounts Regular Expression /// ...
Please Sign up or sign in to vote.
6 Nov 2011
RaisKazi
Have a look at below Articles.Learn Regular Expressions (RegEx) with EaseThe 30 Minute Regex Tutorial
Please Sign up or sign in to vote.
20 Nov 2011
RaisKazi
Have a look at below CodeProject Articles on "Regular Expressions".The 30 Minute Regex TutorialLearn Regular Expressions (RegEx) with Ease
Please Sign up or sign in to vote.
13 Jan 2012
OriginalGriff
In this case, try:ClosedAccountFile_(\d+)_(\d+)_(\d+)_(\d+).txtThis matches your example, and separates each of the numeric values out into it's own group within the match.You have top realize that Regexes are much, much more complex than SQL LIKE statements - the simplest form of "%" in a...
Please Sign up or sign in to vote.
2 Feb 2012
cutexxbaby
2 alternatives  
how to change this regular expession to must have two decimal place((0)+(\.[1-9](\d)?))|((0)+(\.(\d)[1-9]+))|(([1-9]+(0)?)+(\.\d+)?)|(([1-9]+(0)?)+(\.\d+)?) cause i try 0.0123 it work but if i try 1.123 it don't wok, if i try 0.1 is don't worki have try this...
Please Sign up or sign in to vote.
2 Feb 2012
OriginalGriff
Try:Regex regex = new Regex("[a-zA-Z]");string result = regex.Replace(InputText,"#");Get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.
Please Sign up or sign in to vote.
6 Feb 2012
Andreas Gieriet
If you want to remove the whole select element with it's content, then you can do it with regex only if some constraints are met: no nested element of the same name (select in this case).Try this:string pattern = @"";CheersAndi
Please Sign up or sign in to vote.
15 Feb 2012
Andreas Gieriet
I think the following Regex and HtmlDecode would do:string html = ...;string textonly = HttpUtility.HtmlDecode( Regex.Replace(html, @"|", ""));Any HTML construct that would not be stripped off properly by this?
Please Sign up or sign in to vote.
12 May 2012
funboysclub
From Pins to Poops, your bookmark bar can do more. Read about the Skidmarklet... a JavaScript Bookmarklet and lessons in RegEx.
Please Sign up or sign in to vote.
13 Jun 2012
OriginalGriff
Try:^[1-9][0-9]{0,5}$
Please Sign up or sign in to vote.
18 Jun 2012
Prasad_Kulkarni
Try this:^(?=[0-9]{3,6}$)0*[1-9][0-9]{2,5}
Please Sign up or sign in to vote.
18 Jun 2012
OriginalGriff
This is a bit rough, because you don't describe it well:[1-9][0-9,]{0,5}Get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.
Please Sign up or sign in to vote.
9 Jul 2012
Manas Bhardwaj
I guess it should be like this:bool result1 = Regex.IsMatch("ABCDEF", @"^[A-Z]{2}$");bool result2 = Regex.IsMatch("ABCDEF", @"^[A-Z]{2,2}$");bool result3 = Regex.IsMatch("AB", @"^[A-Z]{,2}$");bool result4 = Regex.IsMatch("AB", @"^[A-Z]{2,2}$");If a caret (^) is at the beginning...
Please Sign up or sign in to vote.
8 Sep 2012
ridoy
http://www.java2s.com/Code/Java/Regular-Expressions/JavaRegularExpressionSplittext.htm[^]http://www.regular-expressions.info/java.html[^]http://www.javamex.com/tutorials/regular_expressions/splitting_tokenisation.shtml[^]http://forums.codeguru.com/showthread.php?292394-TIP-A-little-tutorial...
Please Sign up or sign in to vote.
19 Sep 2012
Aarti Meswania
if it is Windows Applicationset property of Textbox CharacterCasing = Lowerit will automatically convert uppercase letters to lowercase.string pattern="^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,3})$";and verify it when textbox's Leave event...
Please Sign up or sign in to vote.
30 Sep 2012
Yvan Rodrigues
^([a-zA-Z0-9](?(?!__|--)[a-zA-...
Please Sign up or sign in to vote.
16 Nov 2012
MT_
I tried this in C# and it worked fine.Regex regex = new Regex("\'");string[] lines = File.ReadAllLines("d:\\milind.txt");foreach (string line in lines){ string str = regex.Replace(line, ""); Console.WriteLine(str);}Hope that helps. If it does, mark it as...
Please Sign up or sign in to vote.
4 Feb 2013
Manfred Rudolf Bihy
What you are searching for is not a case for using Regular Expressions. RE's allow you to quantify how many characters of a set may occur in a row, but not how many in total. Writing a regular expression for what you are trying to do is not possible.You're better of doing this with a...
Please Sign up or sign in to vote.
4 Feb 2013
Zoltán Zörgő
Manfred R. Bihy's answer is mainly correct. But regexp is capable of counting total character counts using lookaheads (please look at this article: http://www.zorched.net/2009/05/08/password-strength-validation-with-regular-expressions/[^]). But strong password validation usually goes beyond...
Please Sign up or sign in to vote.
19 Feb 2013
Joezer BH
Hello Paw,Here's a pattern to find the LON and then insert it into a group called "lon":string patternToFindLON = @"lon(\s|:)*(?[0-9]*(.[0-9]*))";And the same idea to find the LATCheers, Edo
Please Sign up or sign in to vote.
20 Feb 2013
Joezer BH
Try this:string regexSearch = new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars());Regex r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));Cheers, Edo
Please Sign up or sign in to vote.
19 Mar 2013
Sergey Alexandrovich Kryukov
An attempt of applying Regular Expressions to extract data from HTML is a very usual in the beginners, and, in most cases, is a methodological mistake. First of all, it's most usual case when HTML is a well-formed XML. In this case, .NET XML parsers should be used, and they are always available....
Please Sign up or sign in to vote.
11 Apr 2013
OriginalGriff
You haven't used groups in your Regex! So all you will get is the whole string matched.I'm just guessing that you want to break out the title and the human readable segment separately?Try this:\w+)">(?.+?)This breaks out two groups:...
Please Sign up or sign in to vote.
10 May 2013
André Kraak
I found a similar question on Stack Overflow[^] and used its answer on your problem.The idea is to split only on comma's that have an even number of or no single quotes after it.Using this expression I got the result without the additional blank line you are looking for....
Please Sign up or sign in to vote.
23 May 2013
OriginalGriff
This is not a "good" regex problem: what you really want to do is use a regex to find if a string contains any "special" characters, then count the number of non-special characters. But your description basically comes down to: you can use any characters you like, but you must have at least one...
Please Sign up or sign in to vote.
3 Jun 2013
Maciej Los
Have a look here: http://regexlib.com/Search.aspx?k=ISBN&AspxAutoDetectCookieSupport=1[^]. There you'll find a solution ;)In my opinion this regex:ISBN(-1(?:(0)|3))?:?\x20+(?(1)(?(2)(?:(?=.{13}$)\d{1,5}([ -])\d{1,7}\3\d{1,6}\3(?:\d|x)$)|(?:(?=.{17}$)97(?:8|9)([...
Please Sign up or sign in to vote.
25 Jul 2013
good.shankar
3 alternatives  
Hai,I have some HTML Text. When i display that i want to highlight some keywords. I dont want to match if that is a part of html tag or any special characters like  for eg :My HTML Text : Hello  Welcome to my Spa No. 160my keywords : spa 160for highlighting i use...
Please Sign up or sign in to vote.
12 Sep 2013
Maciej Los
Have a look here: Regular Expression Language - Quick Reference[^]Regular Expression Basic Syntax Reference[^]
Please Sign up or sign in to vote.
12 Sep 2013
CHill60
The hyphen is the key part, the regex is saying match any character in the range "+" to "x" or *For example ")" and "z" would not matchNot sure why it isn't just [\*-x] to be honest.
Please Sign up or sign in to vote.
18 Sep 2013
Maximilien
1 alternative  
Is it possible to use std::tr1::regex_iterator to search and replace in a string ?I know I can use std::tr1::regex_replace to replace all occurrences (or only one), but I need to replace each "pattern" that I find with something different, so I need to iterate my input string and replace on...
Please Sign up or sign in to vote.
11 Oct 2013
Andreas Gieriet
I would split the whole thing into scanning and parsing.According to your spec, the overall pattern looks as follows:begin, 1-to-2-digits, 1-char, 2-chars, 2-evenly-split-digit-groups-of-up-to-4-digits-each, endWhere between all tokens, there may be zero or more spaces.Lets define...
Please Sign up or sign in to vote.
18 Oct 2013
BillW33
Although you have solved your problem I am posting this to help those wanting to better use RegEx. A very helpful site is regexlib[^]; they have a large library of Regular Expressions. They also have a RegEx tester[^]. Also a very useful RegEx tool is available here.
Please Sign up or sign in to vote.
24 Oct 2013
codestar007
1 alternative  
Hi allI wrote this expression for validating % in textbox^100(\.0{0,2})? *%?$|^\d{1,2}(\.\d{1,2})? *%?$Its working fine with input like 20.88%but when i give 20.88 i.e. without %, that also it's taking..this i don't wantPlease tell me what i am doing wrong..??
Please Sign up or sign in to vote.
2 Nov 2013
OriginalGriff
If you aren't sure, then the best thing to do is to get a copy of Expresso: http://www.ultrapico.com/expresso.htm[^]It's free, and it explains, helps you create and tests Regexes - I use it all the time and really wish I'd written it. (And I wish it came in an Android version, too)."\*"in...
Please Sign up or sign in to vote.
19 Nov 2013
♥…ЯҠ…♥
Hi Bala,Here is the regex for dollar symbol^([0-9]{1,3}\$?)$ (dollar optional here)If dollar mandatory at last with single appearance then use this ^([0-9]{1,3}\$)$ or ^([0-9]{1,3}\${1})$ (dollar mandatory here)will allow 100$, 111$, 001$, 123$.For indian currency you can...
Please Sign up or sign in to vote.
21 Jan 2014
Ron Beyer
Here is a way to do it without RegEx: class Program { static void Main(string[] args) { string fileName = "CheckFileList.txt"; Dictionary> sections = GenerateList(fileName); foreach (string sectionName...
Please Sign up or sign in to vote.
18 Feb 2014
OriginalGriff
To be honest, a regex is a poor way to do this: regular expressions are very good at pattern matching, but they are very poor are syntactic analysis, which is what this task requires.It is possible to match brackets and so forth - though it is quite complex - but it can't easily spot things...
Please Sign up or sign in to vote.
20 Feb 2014
Sergey Alexandrovich Kryukov
Please see my comment to the question.You just need to learn System.DateTime and methods of parsing of string into date data. Please see all the methods named Parse, ParseExact, TryParse and TryParseExact (and avoid using Convert, in most cases; after all, this is parsing, not...
Please Sign up or sign in to vote.
15 Apr 2014
Sampath Lokuge
\s matches whitespace (short for [\f\n\r\t\v\u00A0\u2028\u2029]).Please take a look at this : Regular Expressions patterns
Please Sign up or sign in to vote.
21 Apr 2014
OriginalGriff
Either[0-9a-zA-Z]+:for "one or more", or[0-9a-zA-Z]*:for "zero or more"But you may find this better:\w+:for "one or more", or\w*:for "zero or more""\w" is the equivalent of "[0-9a-zA-Z_]"
Please Sign up or sign in to vote.
6 May 2014
CHill60
Try this ^(?=.*[a-zA-Z]+.*)[0-9a-zA-Z]{6,15}$Which I adapted after typing "Password" into the search engine at Regxlib.com[^]
Please Sign up or sign in to vote.
7 May 2014
Peter Leow
It has got nothing to do with regex, just use javascript to validate before submissioncheck-box-validation-for-atleast-one-check-box-should-cheked-in-asp-net[^]
Please Sign up or sign in to vote.
13 Jun 2014
phil.o
Maybe:const string EIDPattern = @"^(?[A-Za-z0-9]{4})(?:[/\s])(?[A-Za-z0-9]{5})(?:[/\s])(?[A-Za-z0-9]{2})$"TheInput string can have space or other symbols also.is not directly translatable to a valid regular expression statement, though.You should...
Please Sign up or sign in to vote.
9 Jul 2014
George Jonsson
Hi,Change your expression to this:string pattern = "(?=.*\bgoods\b|\bitems\b|\bthings?\b)(?=.*\bbought\b)(?=.*\bid\b)(?=.*\btest\b).*";Putting a ? after the 's' in 'things?' will catch both thing and things.You need to have word boundaries around each word in the optional...
Please Sign up or sign in to vote.
29 Oct 2014
Peter Leow
Try this, decimal number with only a "5" after decimal point.^\d*.5$
Please Sign up or sign in to vote.
7 Nov 2014
Manas Bhardwaj
Regular Expressions[^] do not change for a different language. The current regular expression in it's form should work in C# as well.
Please Sign up or sign in to vote.
12 Nov 2014
Maciej Los
Something like that should do the work: List exp = new List(); exp.Add("#:t.Brand"); exp.Add("#:iF(12 > 10,t.price,t.description)"); exp.Add("#:t.Brand + 'and ' + t.SubBrand"); System.Text.RegularExpressions.Regex searchTerm = new...
Please Sign up or sign in to vote.
21 Nov 2014
Matt T Heffron
Why not just have the Regex do the replacement?private string ReplaceProductDescription(string description){ string pattern = @"/en/products/(?\d{4})/(?\d{4})\.aspx"; Regex regEx = new Regex(pattern); return regEx.Replace(description, "newString pn1 here:${pn1} pn2...
Please Sign up or sign in to vote.
8 Dec 2014
George Jonsson
This is one way to do it.string input = "ABC_V3_Weekly_Abcdef_from_NOV_05_to_NOV_12";Regex regex = new Regex(@"from_(?[A-Z]{3})_(?[0-9]{2})_to_(?[A-Z]{3})_(?[0-9]{2})", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant | RegexOptions.Multiline...
Please Sign up or sign in to vote.
12 Dec 2014
Andreas Gieriet
How about this - not RegEx, but produces also the desired result:var names = new string[]{ "Anitha", "Nandu", "anushka", "jayasree"};string[] anu = names.Where(n=>n.IndexOfAny("aA")>=0) .Where(n=>n.IndexOfAny("nN")>=0) ...
Please Sign up or sign in to vote.
10 Mar 2015
Praneet Nadkar
Hi,You can try this:var regex = new Regex( "(\\)|(\\)", RegexOptions.Singleline | RegexOptions.IgnoreCase);string ouput = regex.Replace(yourString, "");This worked for me. Hope this helps !! :) :)
Please Sign up or sign in to vote.
28 May 2015
Maciej Los
Try this: (\+\d+[a-zA-Z])|(.\+\d+)|(\d+\+)
Please Sign up or sign in to vote.
20 Sep 2015
PIEBALDconsult
Right, well obviously that method can't handle C/C++/C# syntax; it's actually pretty limited in what it can do.Fortunately, .net allows you to compile code at run-time. There are several articles here on CP, including mine: Compiling Source Code from a String[^]
Please Sign up or sign in to vote.
28 Oct 2015
CPallini
You have to somehow parse the JavaScript source code, in order to extract such a info.You may have a look at existing parsers (Google is your friend[^]).
Please Sign up or sign in to vote.
14 Nov 2015
George Jonsson
You have a syntax error in your expression. You are using ( instead of [.So change the expression from^(a-z)+\(+(a-z)+\,+(a-z)+\) $to^[a-z]+\(+[a-z]+\,+[a-z]+\);$I also replaced the white space with a ;
Please Sign up or sign in to vote.
16 Dec 2015
OriginalGriff
The year is the problem - the rest of it is trivial.I would do the year validation as a separate operation: extract it as part of the regex, then check it as a valid year in code rather than try to do it as a regular expression operation.The reasons are twofold1) Year validity changes...
Please Sign up or sign in to vote.
20 May 2016
George Jonsson
Regular expressions are not the best tool for this, because you will have nested parts of your input text.In this case it with be more robust to use a parser, but that has a bit of a learning threshold. ANTLR4 is a free parser originally for Java, but it has a version for C# as well. See...
Please Sign up or sign in to vote.
28 Sep 2016
OriginalGriff
The problem is that "?" means just that: "0 or 1 repetition of the preceding item"Which means it's optional.Take the "integer number" regex:^[+-]?\d+$What that says is "the whole string consists of at least one digit, which may be preceded by a single plus or minus"So it...
Please Sign up or sign in to vote.
13 Jan 2017
OriginalGriff
Well, the regex should work. But ... your code doesn't care what happens if it does or doesn't work in that all you do is put up a message box if it fails and continue.Probably, you need to add an Else clause to the click handler to do something specific when the pattern does match. But we...
Please Sign up or sign in to vote.
8 Nov 2017
Karthik_Mahalingam
Not using Regex var input = 'fgsdfg $sdfsdgf$ sdfas $dgfdg$'; var words = input.split(' '); var tempOutput = []; for (var i = 0; i
Please Sign up or sign in to vote.
1 Mar 2018
Medtronic WPF Developer
1 alternative  
Hello I believe that there is a better way to use RegEx in C# than I have done below: public override object ProvideValue(IServiceProvider serviceProvider) { Regex r = new Regex("{.+}"); var matches = r.Matches(String); var replacer = new...
Please Sign up or sign in to vote.
1 Mar 2018
Richard Deeming
Something like this should work: private static readonly Regex Pattern = new Regex("{(.+?)}", RegexOptions.Compiled); public override object ProvideValue(IServiceProvider serviceProvider) { return Pattern.Replace(String, match => { string newMatch = match.Groups[1].Value; ...
Please Sign up or sign in to vote.
9 May 2018
RickZeeland
Here is a nice extension class that will make regex searches a lot simpler: I don't like Regex...[^] You can search using a wildcard like * and the result will contain the found string. I modified it a little so * also includes spaces in the result and users don't need to use %: static...
Please Sign up or sign in to vote.
9 May 2018
OriginalGriff
If you mean HearingDocExtract, DocumentCopy, and DocumentID Then this will do it: (['])(?:(?=(\\?))\2.)*?\1 using System.Text.RegularExpressions; /// /// Regular expression built for C# on: Wed, May 9, 2018, 05:43:42 PM /// Using Expresso Version: 3.0.4750, http://www.ultrapico.com...
Please Sign up or sign in to vote.
14 Mar 2019
Thomas Daniels
A digit is \d. A repetition can be implemented using {N} (meaning that a char or group must be repeated N times). With that, your regex becomes: ^\d{3}/[A-Z]{2}\d{2}/\d{9}/\d{2}$ Test it here: Online regex tester and debugger: PHP, PCRE, Python, Golang and JavaScript[^] string regex =...
Please Sign up or sign in to vote.
23 Mar 2020
Richard Deeming
I'm guessing somewhat here, but I suspect you're using the Validating[^] event to validate your textbox, and that's preventing you from clicking on your "exit" button unless you've entered a valid value. If that's the case, you need to set the...
Please Sign up or sign in to vote.
21 Sep 2020
Patrice T
Quote: Can someone help? The principle of regex is to match variable strings, to explain what you want, you need to give examples inputs and matched strings to let us know what you want, a few input that will be rejected may help too....
Please Sign up or sign in to vote.
10 Jan 2018
ASkaeff
A simple yet powerful tool to analyze SQL object dependencies in quite a fast and reliable manner.
Please Sign up or sign in to vote.
26 Jul 2010
xJorDyx
1 alternative  
This is one of my regular expressions:(?[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?),(?[-+]?[0-9]*\.?[0-9]+([eE][-+]?[0-9]+)?)The input would be 2 floats separated by a comma2.34,-23It creates 2 main groups "RollP" and "RollI" and i want to be able to take the...
Please Sign up or sign in to vote.
17 Nov 2010
Fredrik Bornander
Try this;using System;using System.Text;using System.Text.RegularExpressions;namespace SomeNameSpace{ class Program { private static string input = "VMMAnalogs_Acquire.c 1.26 2001_105/02 2001_105/02\n" + ...
Please Sign up or sign in to vote.
4 Dec 2010
User970
2 alternatives  
I have a text file that I want to split with RegEx, but the problem is that its syntax is something like this:["string", "string", [("string", int),("string", int)], int, int, string(int, "string")],I want to split it using the comma (,) as a delimiter, but as you can see, there are a lot of...
Please Sign up or sign in to vote.
4 Jan 2011
Hiren solanki
Regular expression isn't there to help you in such a situation.Whatever your HTML tag is will give you finally out put in a browser in a pattern of what you wanted actually, What you want to achieve using Regex.Dot is a HTML display for unordered li tags.and number is a HTML display...
Please Sign up or sign in to vote.
7 Jan 2011
Hiren solanki
Other then Masked textbox using Ajax, You will also find this simple TRICK[^] with simple JS useful.
Please Sign up or sign in to vote.
18 Jan 2011
KevinAG
Sorry, but I have to vote this way down. Your regular expression (or @Chris's) is not robust enough for what I would consider "real world" data. Especially if this is used on any kind of public web site, I would be afraid of JavaScript injection attacks and other things (depending on its usage)....
Please Sign up or sign in to vote.
16 Jan 2011
Estys
The regular expression to serch for would be ">\s{2,}
Please Sign up or sign in to vote.
21 Jan 2011
Sandeep Mewara
Well, this is a repost[^] of your earlier question with changed content a little. Please avoid posting the same stuff multiple times. Follow at one place. Asking for code is not going to help. Try and then post the issue you face.
Please Sign up or sign in to vote.
21 Jan 2011
Hiren solanki
My complete work for you in a free time.String HTMLStr = "Hi Hello How r u. "; Regex regex = new Regex("\\]*\\>"); MatchCollection...
Please Sign up or sign in to vote.
7 Feb 2011
OriginalGriff
You don't need a Regex to do that: you can just use the string.Replace method:string inp = "hello there\n/* Call SUT */goodbye";inp = inp.Replace("/* Call SUT */", "/* Lower LOG level to improve performance and decrease output file size. */\n" + ...
Please Sign up or sign in to vote.
26 Feb 2011
DaveAuld
Well,Based on this; http://regexlib.com/REDetails.aspx?regexp_id=564[^]I substiuted ABCD for TBRL and got this;(?i:([TBRL])(?!\1)([TBRL])(?!\1|\2)([TBRL])(?!\1|\2|\3)([TBRL])) Didn't work length had to be 4Try...
Please Sign up or sign in to vote.
26 Feb 2011
Henry Minute
The first part of your question is not difficult, something like "[RBLT]{4}" would do it.The 'no duplicates' is difficult and in my opinion not suitable for a regular expression. This[^] article agrees.Although there are some regex wizards on CP that might give different advice.
Please Sign up or sign in to vote.
26 Feb 2011
Sergey Alexandrovich Kryukov
It should be three steps: first, compare string with string.Empty (or first with null, or use string.IsNullOrEmpty). As a second step, use [RBLT]{4}, as Henry correctly put it. Third: with Regex, find all matches and then compare them in a loop to find duplicates and select only one match in...
Please Sign up or sign in to vote.
10 Apr 2011
Ashishmau
u can do like this alsostring s = "domain\\username"; string a = s.Substring(s.IndexOf("\\")+1);Hope it helps
Please Sign up or sign in to vote.
10 Apr 2011
JF2015
Try these solutions:http://stackoverflow.com/questions/4377921/how-do-i-check-for-multiple-date-formats-in-regex[^]
Please Sign up or sign in to vote.
29 Apr 2011
Kim Togo
You can use LINQ to XML. It is very nice to work with.LINQ to XML Overview[^]
Please Sign up or sign in to vote.
29 Apr 2011
Sergey Alexandrovich Kryukov
In addition to what Kim and Manfred proposed, I'll add:You need to create an XML schema and validate XML against the schema, please read this: http://msdn.microsoft.com/en-us/library/system.xml.schema.xmlschemavalidator.aspx[^].General conclusion: application of Regex to XML is totally...
Please Sign up or sign in to vote.
2 May 2011
Kim Togo
Try this regexp^at\s+(?.+?),.+?\(.+?longitude\s+(?.+?),latitude\s+(?.+?)\)\s+in\s+(?.+?),the depth.+?\s+(?\d+)/// A description of the regular expression:/// /// ^at\s+/// Beginning of line or string/// at/// ...
Please Sign up or sign in to vote.
19 May 2011
Kim Togo
Try this bade boy of a regex string: \b(?=[-/\\\\A-Za-z]*[0-9])(?=[-/\\\\0-9]*[A-Za-z])[A-Za-z0-9]+(?:[-/\\\\][A-Za-z0-9]+)*\bIt will find only strings that contains numbers.string like this "Dam It12 is not45 that g00d".Will give...
Please Sign up or sign in to vote.
19 May 2011
Deepthi Aravind
string abc = "deepthi12 " char[] SpecialChars = "0123456789";.ToCharArray(); int indexOf = abc.IndexOfAny(SpecialChars); if (indexOf != -1) { //there should a number in the string } else ...
Please Sign up or sign in to vote.
4 Aug 2011
Roliking
2 alternatives  
Hello All, I want to validate my textbox and email fields not to contain >> ( ) { } [ ] ? & * ~ ` ! # $ % ^ = + | \ : ' " , ; these special characters and can contain - _ @ / . these sepcial characters.How can i do it?Thanks in advance,Regards.
Please Sign up or sign in to vote.
4 Aug 2011
OriginalGriff
The simple regex is easy: @"[^\...]" where the elipsis is the list of individual characters you want to prohibit.However, I would suggest that a better email address validation would be a good idea, especially since '@' is not a legal character in an email address (it is the separator...
Please Sign up or sign in to vote.
4 Aug 2011
thatraja
I recommend the following freeware to regular expression thingsExpresso 3.0 - The premier regular expression development tool[^]
Please Sign up or sign in to vote.
4 Aug 2011
Christian Graus
I suggest you download the program expresso. It helps you build regular expressions and test them. Also, 9 out of 10 real programmers know how to do something like this[^].
Please Sign up or sign in to vote.
18 Aug 2011
BoxyBrown
3 alternatives  
Hi all.Is it possible to split input text into list of words. Words should contain only symbols.for ex. "This is Peter's 5th program." I want to get words: "This", "is", "Peter", "program".Can I do it using only regular expressions? Or it is better to use myString.Split(' '), analyse...
Please Sign up or sign in to vote.
18 Aug 2011
Sergey Alexandrovich Kryukov
I would start with Split. The problem is not really up to Regex, which is also would be hard to support.—SA
Please Sign up or sign in to vote.
22 Aug 2011
OriginalGriff
Google! A very simple search using "validate alphanumeric in javascript" copied from your question subject gave 1.3 million hits, most of then explaining exactly how to do it.Please, try to do at least basic research your self in future...
Please Sign up or sign in to vote.
22 Aug 2011
CPallini
It is time to learn both Javascript and regular expressions (and, in the spare time, have a look at the Q&A FAQ).
Please Sign up or sign in to vote.
8 Sep 2011
sravani.v
^[A-Z]{2}([ \-])[0-9]{2}[ ,][A-Z0-9]{1,2}[A-Z]\1[0-9]{4}$
Please Sign up or sign in to vote.
9 Sep 2011
#realJSOP
Why use regex? // I would personally make this an extension methodpublic static string ReplaceOccurrence(this string str, string target, string replacement, int count){ int pos = -1; int counted = 0; string result = ""; do { pos = (pos >= 0) ?...
Please Sign up or sign in to vote.
15 Sep 2011
OriginalGriff
There is no sensible regex which will do that - it is a job for a sort routine.The easiest way is to convert the string to a character array, sort it, and convert back to a string again.string s = "bcade";char[] chars = s.ToCharArray();Array.Sort(chars);s = new...
Please Sign up or sign in to vote.
22 Sep 2011
Tommi Kemppi
3 alternatives  
Hi, I have an IE7 spesific REGEX problem.I'm validating Email Address with the following regex:^\s*[a-zA-Z0-9_\+-]{1,63}(\.[a-zA-Z0-9_\+-]{1,63})*@(?=[a-zA-Z0-9-\.]{0,255}\.?\s*$)[a-zA-Z0-9-]{1,63}(\.[a-zA-Z0-9-]{1,63}){0,126}\.([a-zA-Z]{2,63})\.?\s*$This works every modern browser but...
Please Sign up or sign in to vote.
30 Sep 2011
PJ Arends
2 alternatives  
I recently downloaded some source files that seem to be exactly what I need for a project of mine. The only problem is that it is written for ANSI builds only, it has no UNICODE support.I now want to change all string literals from "text text" to _T("text text") by wrapping them in the _T...
Please Sign up or sign in to vote.
30 Sep 2011
Mehdi Gholam
Try this :search for : \".*\"replace with : _T(\0)
Please Sign up or sign in to vote.
24 Oct 2011
OriginalGriff
If you need to understand a Regex, get a copy of Expresso [^] - it's free, and it examines, explains and generates Regular expressions.
Please Sign up or sign in to vote.
15 Nov 2011
Not Active
Why even bother with the validation. Don't allow a date/time to be entered as text, use a calendar control. Or use DateTime.TryParse to validate
Please Sign up or sign in to vote.
20 Nov 2011
R. Giskard Reventlov
It is a regular expression: you can learn about them by starting here[^] and reading through some of the tutorials.
Please Sign up or sign in to vote.
20 Nov 2011
Uday P.Singh
Have a look at this article to get started in Regular Expression:An Introduction to Regular Expressions[^]hope it helps :)
Please Sign up or sign in to vote.
20 Nov 2011
jeet786
this is one type of Regular expression.You can get the different type of regular expression from the site:http://regexlib.com/UserPatterns.aspx?authorid=0ebe8f93-b71b-4d1c-bfc2-0b583c464641[^]
Please Sign up or sign in to vote.
21 Nov 2011
moneymakermaster
http://www.regular-expressions.info/reference.html[^]
Please Sign up or sign in to vote.
26 Nov 2011
RaisKazi
Have a look at below articles.The 30 Minute Regex TutorialLearn Regular Expressions (RegEx) with Ease
Please Sign up or sign in to vote.
14 Dec 2011
AspDotNetDev
Try this:\]*>[^>]*\>
Please Sign up or sign in to vote.
22 Dec 2011
Drazen Pupovac
I tried and its works: List list = new List(); list.Add("ASD"); list.Add("ASFsdsd"); list.Add("adsASFsdsd"); string pattern = @"[A-Z]{3}"; Regex regex = new Regex(pattern); List result = new List(); foreach (string val in...
Please Sign up or sign in to vote.
13 Jan 2012
Member 8566049
2 alternatives  
Hi,I spent long time to figure out making the search with regular expressions in C# as it is done in SQL. I cannot find the equivalent of '%' sign of SQL in C#. I have tried to use "(|)" but it gives the 'or' condition.I am wondering if I can use the grouping with "and" condition on...
Please Sign up or sign in to vote.
14 Jan 2012
thatraja
Here you goExpresso - A Tool for Building and Testing Regular Expressions[^]The 30 Minute Regex Tutorial[^]
Please Sign up or sign in to vote.
14 Jan 2012
psychic6000
here is the ReGex i use for password fields... all the letters and symbols are allowed, and range is from 0 to maximum... * represents= 0 or more than 0 can exists^[a-zA-Z0-9]*[!,@,#,$,%,^,&,*,?,_,~,-,£,(,)]*$but this will not allow a letter once a symbol is entered...so you can modify it...
Please Sign up or sign in to vote.
2 Feb 2012
CRDave1988
I hope this will Solve ur problemhttp://lawrence.ecorp.net/inet/samples/regexp-format.php[^]http://www.funduc.com/regexp.htm[^]
Please Sign up or sign in to vote.
23 Mar 2012
Sebastian T Xavier
I have solved this by changing the expression as follows...Regex rx = new Regex(@"password='([a-zA-Z0-9\\%^&_*]+)\'");--------------again i have another question... Here is my updated expression...string x = "user = 'sa' password='e X65dere!@#$%^&*()' server = 'localhost'";Regex...
Please Sign up or sign in to vote.
3 Apr 2012
fjdiewornncalwe
Really awesome tool, google is. Use it sometime, you should. Yes, hmmm.phone number regex[^]
Please Sign up or sign in to vote.
16 May 2012
Jean-Francois Lanouette
4 alternatives  
Hi, In our application we have many fields that are validated by using a regex. When the user enter an invalid data we show an error message. What I'm looking for is a way to create an example of a valid entry based on the regex we used to validate the field.I know that there's already...
Please Sign up or sign in to vote.
18 May 2012
VJ Reddy
The reason is that , is not to be escaped. So \, is interpreted as \ and , characters separately hence the required match is not found. Further .* in start is not necessary and \s* is also not necessary as . matches white space too. So the following pattern can be used\(.*,.*,.*\) but...
Please Sign up or sign in to vote.
26 May 2012
Member 8491154
2 alternatives  
I have a long string of characters as input and I want to count the number of words in that string. How can I do it through regular expression?
Please Sign up or sign in to vote.
14 Jun 2012
Sunny_Kumar_
1 alternative  
Hi,I want to verify the characters entered in excel sheet' cell using vba. I'm trying this with the pattern "^[a-zA-Z0-9]{21,21}$". I want this to match exactly 21 characters (can be alphanumeric) and no more or less than that. Its working fine when the characters are less than 21 characters...
Please Sign up or sign in to vote.
21 Jun 2012
FrewCen
3 alternatives  
Hi all. I have small problem I have some input text. I want to match that text but only then, when it not contains some words. I know how to do similar thing with characters ([^ChArAcTeRsWhItChIdOnTwAnT]). So my question is: is there any way how to get text starting with some words and ending...
Please Sign up or sign in to vote.
25 Jun 2012
OriginalGriff
I wouldn't use a regex directly - I would de-regionalize my data first. This is the way I do it:/// /// Remove Diacritics from a string/// This converts accented characters to nonaccented, which means it is/// easier to search for matching data with or without such accents.///...
Please Sign up or sign in to vote.
29 Jun 2012
R. Giskard Reventlov
Let me Google[^] that for you.
Please Sign up or sign in to vote.
29 Jun 2012
Dave Kreskowiak
Not in Google, huh?Then explain how I found this[^], this[^], and this download site[^] for the documentation.EDIT:And I forgot to post this guide[^] on understanding EDIFACT.I found that stuff in all of 10 seconds on Google. You really need to upgrade your Google-Fu skills.
Please Sign up or sign in to vote.
4 Jul 2012
Raje_
your confusion are for sure. let me try to remove your confusion.[..] :- it means it has explicit set of character to match.^ :- it means start of string.$ :- it means end of string.there are more like--\ :- preceding one of the above or down.. :- any character except new...
Please Sign up or sign in to vote.
5 Jul 2012
OriginalGriff
Regexes are clever beasts, one opf the overloads for Rexex.Replace uses a match evaluator delegate: http://msdn.microsoft.com/en-us/library/cft8645c.aspx#Y0[^] which allows you to do further processing on the text matched by the Regex.If you write your routine to compare the match text as...
Please Sign up or sign in to vote.
5 Jul 2012
Rahul Rajat Singh
I think this article could be of some help.Find and Replace with Regular Expressions[^]
Please Sign up or sign in to vote.
9 Jul 2012
Vitaly Tomilov
2 alternatives  
Guys,I've got a little lost with regular expressions in .NET 4.0. Can't understand why RegEx ignores maximum length in the pattern. See the code below...using System;using System.Text.RegularExpressions;namespace RegExTests{ class Program { static void Main() { bool...
Please Sign up or sign in to vote.
12 Jul 2012
Mehdi Gholam
Try the following:\s+\d{1,6}\s+It will give you 1234 with the following data :12345671234abc1111
Please Sign up or sign in to vote.
23 Jul 2012
vaibhav mahajan
2 alternatives  
Hello everyone,I need to write a regular expression which will allow numbers like1.23 and 1in to the text-box. Decimal point is not the compulsion.Any suggestion or links are welcome..!!
Please Sign up or sign in to vote.
23 Jul 2012
Vedangi
Regular Expression is : ^[0-9]\d{0,9}(\.\d{1,3})?%?$ [0-9] : for integers which allows integers from 0 to 9 d{0,9}: this will take up to 10 digits \. : for decimal d{1,3} : for decimal up to three digits
Please Sign up or sign in to vote.
26 Jul 2012
sjelen
Try something like this:\[down]([^"]+)"[^(?[^\s*)+\[/down]
Please Sign up or sign in to vote.
29 Jul 2012
Christian Graus
Probably (?!.*validate)password(?!.*validate), so it checks before and after.
Please Sign up or sign in to vote.
19 Aug 2012
OriginalGriff
It's complex - but possible:^.*(?=.{8,10})(?=.*[!"£$%^&*()_])(?=.*[a-zA-Z]).*$The characters between the '[' and ']' are the permitted special characters. To be honest, I wouldn't use a regex for this - I'd do it in code, it's a lot more maintainable.
Please Sign up or sign in to vote.
21 Aug 2012
Matt T Heffron
You only need a single RegEx.Use the conditional quantifiers in the Regex:Case eValidateInput.IsPhoneNumberWithPlus Dim objRegEx As New System.Text.RegularExpressions.Regex("^\+?\s?\d{3}\s?\d{3}\s?\d{4}$") If Not objRegEx.IsMatch(InputValue) Then sValidationMsg = "'" &...
Please Sign up or sign in to vote.
29 Aug 2012
fjdiewornncalwe
You have the Required attribute on there. If a value is required it cannot be null. The regular expression has nothing to do with it.
Please Sign up or sign in to vote.
6 Sep 2012
Sangramsingh Pawar
See below article you will find solution yourselfThe 30 Minute Regex Tutorial[^]
Please Sign up or sign in to vote.
6 Sep 2012
BillW33
You should make an effort to learn more about Regular Expressions. A good place to get started is here. Another very helpful site is regexlib[^]; they have a large library of Regular Expressions. They also have a RegEx tester[^]. Also a very useful RegEx tool is available here.
Please Sign up or sign in to vote.
17 Sep 2012
OriginalGriff
So include a space before the match string, and in the replacement.AAAABBB > (CCC + BBB)Search for " BBB" and replace it with " 'BBB'"
Please Sign up or sign in to vote.
25 Sep 2012
Mits Machhi
try this:
Please Sign up or sign in to vote.
26 Sep 2012
Vijay Walunj,Navi mumbai
You can done this in following ways:1.AjaxFilteredTextBoxExtenderhere you first add reference of ajax toolkit and this extender.you can set ValidChars to "." for decimal which allo user to enter numeric value with decimal point.
Please Sign up or sign in to vote.
1 Nov 2012
Niral Soni
try var re = new RegExp('(' + inputfirst + '|' + inputsecond + ')',"g");
Please Sign up or sign in to vote.
15 Nov 2012
Sanjay K. Gupta
In C# If you want to replace the (') with blankstring name=name.Replace("'","");If you don't want to replace the (')string name=name.Replace("'","''");In SQL If you want to replace the (') with blankprint replace('isola d''istria','''','')
Please Sign up or sign in to vote.
12 Dec 2012
Zoltán Zörgő
What about this:^0\d{9}(,0\d{9}){0,9}$
Please Sign up or sign in to vote.
14 Jan 2013
OriginalGriff
Regex is probably the wrong tool, unless you are trying to match that string as a pattern:"A slash, followed by two uppercase Alpha, and three digits, then a other slash, followed by ..."If you want to find an exact string, then use string comparison instead - it's a lot easier and a lot...
Please Sign up or sign in to vote.
20 Jan 2013
Andreas Gieriet
How about:...string input = ...;Match match = Regex.Match(input, @"\w+\s*=\s*(\d+(?:\.\d+)?\s*[A-Z]+)");string size = match.Success ? match.Groups[1].Value : string.Empty;...Depends very much on the input string if the @ and { are relevant to properly match the text.Note: If you...
Please Sign up or sign in to vote.
18 Feb 2013
Manfred Rudolf Bihy
Hi Aarti,there are actually two issues with your example.There is no need for quotes around your pattern literal. Regular Expressions are first class citizens in JavaScript. Look here Regular Expression Cheat Sheet[^] or here W3 Schools RegExp Object[^]Certain characters in Regular...
Please Sign up or sign in to vote.
26 Feb 2013
Mike Meinz
I use TXT2RE Regular Expression Generator to quickly create Regular Expressions.
Please Sign up or sign in to vote.
18 Mar 2013
OriginalGriff
Try:-?\d+Get a copy of Expresso [^] - it's free, and it examines and generates Regular expressions.
Please Sign up or sign in to vote.
21 Mar 2013
Sergey Alexandrovich Kryukov
Thank you for clarification. It finally looks like Regex is not helpful at all.Before entering data, perform filtering, to filter out everything except decimal digits, '.' and backspace (code point 8). Unfortunately, masked edit won't help much. For example, if this is...
Please Sign up or sign in to vote.
31 Mar 2013
Thomas Daniels
Hi,Try Expresso[^]
Please Sign up or sign in to vote.
31 Mar 2013
Kenneth Haugland
This is the one I use:Expresso - A Tool for Building and Testing Regular Expressions[^]OThers are also availiable:http://www.codeproject.com/search.aspx?q=regex+tool&x=0&y=0&sbo=kw[^]
Please Sign up or sign in to vote.
8 Apr 2013
OriginalGriff
That's because '\d' is rexeg-speak for a digit: '0' to '9', Since your string contains "abcdefgh" and no digits at all, it will never match.Try@"DATE=.{7}"for seven of any character, or:@"DATE=\w{7}"for seven alphnumerics, or:@"DATE=[a-zA-Z]{7}"for seven upper or lower case...
Please Sign up or sign in to vote.
10 May 2013
Pallavi Waikar
Try linq with regex examplestring s = @"1.3#, 2.99, 3\t, 4#2/2/1019#, 5, asd,, 'Howdy, Howdy, Howdy', a;sdlkf";string[] myValues = Regex.Split(s, @"(?:,\s+)|(['""].+['""])(?:,\s+)").Where(s2 => !string.IsNullOrEmpty(s2)).ToArray();foreach (string s1 in myValues) MessageBox.Show(s1);
Please Sign up or sign in to vote.
17 May 2013
Sergey Alexandrovich Kryukov
Solution 1 provides right idea. Besides, you may want to do a different thing: instead of validation, you could filter out unwanted character while they are entered. In a Web application, this is done in JavaScript. Just one detail, often forgotten, don't forget to allow "character" #8,...
Please Sign up or sign in to vote.
1 Jul 2013
sjelen
var r = new System.Text.RegularExpressions.Regex("^[a-z0-9&\";,.\\-#@/{}]*$");
Please Sign up or sign in to vote.
8 Jul 2013
ArunRajendra
You should be able to find it in this site. http://regexlib.com/[^]
Please Sign up or sign in to vote.
8 Jul 2013
Thanks7872
Try this ^[A-Za-z0-9- ]+$Regards.. :laugh:
Please Sign up or sign in to vote.
14 Aug 2013
DominicZA
1 alternative  
I am trying to remove all the instances of a number except for a number that I supply. This is currently what I have:var ar = '10,13,9,8,13,10,5,3,1,9,5,8,10,2,6';var removed = ar.replace(new RegExp('[^(' + 10 + ')]', 'g'), '')The result of this is "101110110", but I need it to...
Please Sign up or sign in to vote.
22 Aug 2013
Zoltán Zörgő
Foreworda) Take a long tour here?: http://www.regular-expressions.info/tutorial.html[^]b) Install this little tool, and play with it: http://www.weitz.de/regex-coach/[^]Now the explanation\w stands for "word character", usually [A-Za-z0-9_]. Notice the inclusion of the underscore and...
Please Sign up or sign in to vote.
30 Aug 2013
OriginalGriff
Simple: you have told it not to!If I compact this a bit it may be a bit more obvious:^x+y+(z+)?$Where x, y, and z are the "phrases" in your regex.That requires "one or more x", then "one or more y", then "one or more z" - a minimum of three characters.I don't know exactly what you...
Please Sign up or sign in to vote.
24 Sep 2013
Maciej Los
Try: ^Two as pattern,^ means: match start of string ;)
Please Sign up or sign in to vote.
24 Oct 2013
thatraja
Check these, you could build yourself new expressions.Expresso - A Tool for Building and Testing Regular Expressions[^]Expresso - The 30 Minute Regex Tutorial[^]
Please Sign up or sign in to vote.
26 Oct 2013
Sergey Alexandrovich Kryukov
The question almost contains the answer. Get Match.Value, which is a string, and use it in another Regex's pattern string. Please see:http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.capture.value.aspx[^].—SA
Please Sign up or sign in to vote.
1 Nov 2013
Brian A Stephens
What you want is negative lookbehinds:(?]*|&[^;]*)(\b160\b|\bspa\b)and replace with$1The negative lookbehind syntax is: (?
Please Sign up or sign in to vote.
9 Nov 2013
OriginalGriff
I'm not sure that a regex is exactly what you are looking for here: it isn't a text matching process, it's a pattern matching process. It can't tell the difference between:mid nightandmidnight tonightThey are both "a word" followed by "a space", followed by "a word".But if you want to...
Please Sign up or sign in to vote.
19 Nov 2013
Trapper-Hell
2 alternatives  
Can someone please provide a thorough explanation of what's going on with the Regex below?I was checking some of the features introduced in .NET Framework 4.5 and one of the mentioned benefits was Regex Timeout.In the example the following Regex is used: ^(\d+)+$ on the following text:...
Please Sign up or sign in to vote.
28 Nov 2013
LGSon2
After struggling with google search and reading about balanced group I finally got things working, though I had to alter the pattern slightly to make it work, at least for me :)Regex: ...
Please Sign up or sign in to vote.
6 Dec 2013
Brian A Stephens
First of all, your regex is overly complicated and doesn't quite fit standards for domain names. - You have | pipes inside of bracketed character classes, which are unnecessary since everything inside brackets is already an alternation. Furthermore, it means that you have inadvertently...
Please Sign up or sign in to vote.
13 Dec 2013
BobJanova
You can't do arithmetic with a regex. You can extract the current value with a regex (@"\((\d+)\)$"), do arithmetic on it in code and then replace the value:str = str.Substring(0, str.LastIndexOf('(')) + newValue + ")";
Please Sign up or sign in to vote.
14 Jan 2014
PIEBALDconsult
(?i)\b\d+$ seems to work on the provided text.Oh, and you'll likely need to redirect or pipe the text. (Maybe you already are, but you don't show it.)
Please Sign up or sign in to vote.
23 Jan 2014
Peter Leow
If you want regex pattern for the following sample outputs:text.45example.90value.46then try:\b[a-zA-Z]*[.][\d][\d]\bElse if you only want those alphabets:textexamplevaluethen try:\b[a-zA-Z]*(?=[.][\d][\d]\b)+++++++++++++++++++++++++++++++++++++++++[amended upon...
Please Sign up or sign in to vote.
23 Jan 2014
Peter Leow
Try this:^[a-zA-Z]*[.][\d]+\b
Please Sign up or sign in to vote.
31 Jan 2014
Brian A Stephens
This regex will do it:(\$\d+(,\d{3})*|\d+(,\d{3})*\$)Explanation: - You need to escape the dollar sign, since it's a special character in regex - The main part of the regex is any number of digits possibly followed by combinations of comma and three digit sections - There's an...
Please Sign up or sign in to vote.
14 Feb 2014
Peter Leow
Try this:^(http[s]?://)?[w]{3}[.]([a-z0-9]+[.])+[a-z]{1,3}$Convert the url into small case first before applying this regex pattern.
Please Sign up or sign in to vote.
26 Feb 2014
Kornfeld Eliyahu Peter
Your regex look like this - http://www.regexper.com/#(.*%3F)%3A%5C%5C%7B(.*%3F)%5C%5C%7D%3B[^]I believe this will do better - http://www.regexper.com/#(.%2B%3A)(%5C%7B.%2B%5C%7D)%3B[^]Also - when you have to check a string for repeating pattern use split to find all the parts...
Please Sign up or sign in to vote.
5 Mar 2014
Thomas Daniels
Try this:string textWithEmails = "Christian has christian@email.com. Olof has the email olof@gmail.com. Lars has the emai britt123@oxford.co.uk.";string filteredStr = Regex.Replace(textWithEmails,...
Please Sign up or sign in to vote.
21 Mar 2014
ZurdoDev
The error says that you have to have an instance for the object you are referencing. You are trying to reference without first having created an instance of it which you can't do because it is not static.
Please Sign up or sign in to vote.
8 Apr 2014
Er. Puneet Goel
Text this: Verified by me:Regex for urls with or without http Page$(function()...
Please Sign up or sign in to vote.
15 Apr 2014
Sebastian T Xavier
Modified the expression as shown below and solved this case...private bool IsUrlValid(string url){ Regex urlRx = new...
Please Sign up or sign in to vote.
17 Apr 2014
Sanket Saxena
Try this:((\+*)((0[ -]+)*|(91 )*)(\d{12}+|\d{10}+))|\d{5}([- ]*)\d{6}
Please Sign up or sign in to vote.
28 Apr 2014
thatraja
Google gave me sites like http://regexlib.com/[^], browse thereORCreate yourself. Check theseExpresso - A Tool for Building and Testing Regular Expressions[^]The 30 Minute Regex Tutorial[^]
Please Sign up or sign in to vote.
6 May 2014
Maciej Los
Why to force doors wide open?TSQLParser[^] class will do it for you.SQL Parser[^]Parse Transact SQL to Check Syntax[^]If it wont be enough, let me know and i'll improve my answer ;)
Please Sign up or sign in to vote.
7 May 2014
DamithSL
why regex? you can use client side validation using javascript or jquary jQuery see if any or no checkboxes are selected[^]and you may need do a server side validation, thenCheckBox[] checkboxes = new CheckBox[] { CheckBox1, CheckBox2, CheckBox3, CheckBox4 };if (!checkboxes.Any(c =>...