Click here to Skip to main content
14,976,314 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.
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.
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.
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.
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 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.
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.
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.
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.
6 Dec 2011
FDW
This is less expensive:For any of the next strings, it gives 8:"Mr O'Brien-Smith arrived at 8.30 and spent \t $1,000.99"" Mr O'Brien-Smith arrived at 8.30 and spent \t $1,000.99""Mr O'Brien-Smith arrived at 8.30 and spent \t $1,000.99 "" Mr O'Brien-Smith arrived at 8.30 and...
Please Sign up or sign in to vote.
8 Feb 2012
jsc42
\S does not / did not work on all versions of RegExp on Microsoft JScript / VBScript (sorry to be vague - I just recall having to avoid it because it was flakey). Instead you could try Start([.|\n]*)End (match everything except newline and newline)Update: Checked some old code: I could...
Please Sign up or sign in to vote.
10 Apr 2021
Marijan Nikic
Regex that can be used for parsing Cron Expressions
Please Sign up or sign in to vote.
28 May 2012
Bryian Tan
Regular Expression to validate the file path and extension and it is compatible with JavaScript and ASP.NET
Please Sign up or sign in to vote.
18 Feb 2012
Hiren solanki
5 alternatives  
Remove HTML and get a plain text from inside
Please Sign up or sign in to vote.
30 Jan 2012
Chris Maunder
2 alternatives  
".*" may not be what you want in multi-line strings
Please Sign up or sign in to vote.
25 May 2014
M@dHatter
Custom Javascript replaceAll() using prototype with Case Insensitive Matching!
Please Sign up or sign in to vote.
17 Oct 2011
Pete O'Hanlon
3 alternatives  
Over the last couple of days I've seen numerous examples of people posting about how to count words in a sentence. Disturbingly, these postings recommend suggest counting the number of spaces in the sentence and use that as the basis of a word count.You may be asking why this is a problem. Well,...
Please Sign up or sign in to vote.
22 Oct 2013
Yuriy Nelipovich
The LogJoin tool helps to collect any unstructured data from text files and join it to a simple table representation for easy analysis.
Please Sign up or sign in to vote.
20 Feb 2017
Henryk Filipowicz
A class to read and parse reg files
Please Sign up or sign in to vote.
20 Feb 2013
Joezer BH
A simple regex that replaces ALL the illegal filename or path chars
Please Sign up or sign in to vote.
4 Sep 2011
Ed Nutting
IIS_ASPNet_URLRewriting
Please Sign up or sign in to vote.
30 Jan 2012
Matt T Heffron
For .NET and Perl Regex: Instead of changing the Regex pattern, use the RegexOptions.Singleline (.NET) or "s" modifier (Perl). This enables "." to match newline.
Please Sign up or sign in to vote.
22 Apr 2014
Marco Bertschi
A quick overview why you should abandon Qt's QRegExp class and move on to use QRegularExpression
Please Sign up or sign in to vote.
6 May 2015
FrostedSyntax
Learn how to use regular expressions to find addresses or parts of an address in a given string. These patterns can also be used to verify that a given string is a true address.
Please Sign up or sign in to vote.
30 Dec 2010
santosh poojari
To remove or replace multiple special character from string using sql queries.
Please Sign up or sign in to vote.
14 Feb 2012
Andreas Gieriet
A "single-liner" to decode quoted-printable data.
Please Sign up or sign in to vote.
14 Jun 2015
Marco Bertschi
A short Reference on how you can validate a registry-formatted GUID with a regular expression
Please Sign up or sign in to vote.
12 Mar 2014
mighty-whity
tip for unicode digits in regular expression
Please Sign up or sign in to vote.
17 Dec 2014
Brad Joss
SQL CLR Functions for Zip Compression and Regular Expression evaluations
Please Sign up or sign in to vote.
17 Oct 2012
jahmani
How to extract the inner text from HTML using a Regular Expression.
Please Sign up or sign in to vote.
12 Nov 2012
killing the bug softly...
While developing a web page in fully HTML controls, you may not be able to use ASP.NET's controls, then you may need the help of some JavaScript function for validation.
Please Sign up or sign in to vote.
1 Jan 2010
Brady Kelly
Not only is this very good advice, but also an excellent read. Various reasons to not use RegEx on HTML.[^]
Please Sign up or sign in to vote.
11 May 2015
FrostedSyntax
This tip provides you with several RegEx find and replace patterns to search through and alter HTML and CSS.
Please Sign up or sign in to vote.
7 Oct 2010
Mahendra Kumar Srivastava
Gives splitted values taking csv string as input.