Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Everything / programming / regular-expression

Regular Expression

regular-expression

Great Reads

by Michael D Bray
Filling in text templates from a data source.
by honey the codewitch
A Non-Backtracking Regular Expression Engine for .NET (Core)
by Mahendra Kumar Srivastava
Gives splitted values taking csv string as input.
by Herre Kuijpers
A utility that allows you to enter simple and more complex mathematical formulas which will be evaluated and calculated on the spot

Latest Articles

by Michael D Bray
Filling in text templates from a data source.
by honey the codewitch
A Non-Backtracking Regular Expression Engine for .NET (Core)
by Mahendra Kumar Srivastava
Gives splitted values taking csv string as input.
by Herre Kuijpers
A utility that allows you to enter simple and more complex mathematical formulas which will be evaluated and calculated on the spot

All Articles

Sort by Score

regular-expression 

by Mahendra Kumar Srivastava
Gives splitted values taking csv string as input.
by Bryian Tan
ASP.NET Password Strength Regular Expression. Customize n numbers of upper case, digits, special characters.
by Chris Maunder
".*" may not be what you want in multi-line strings
by 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.
by 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...
by 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.
by honey the codewitch
How to validate fields for things like data entry applications.
by Andreas Gieriet
A "single-liner" to decode quoted-printable data.
by Pete O'Hanlon
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,...
by 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...
by 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 /// ...
by 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...
by Brady Kelly
Not only is this very good advice, but also an excellent read. Various reasons to not use RegEx on HTML.[^]
by 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.
by jahmani
How to extract the inner text from HTML using a Regular Expression.
by Ed Nutting
IIS_ASPNet_URLRewriting
by M@dHatter
Custom Javascript replaceAll() using prototype with Case Insensitive Matching!
by FrostedSyntax
This tip provides you with several RegEx find and replace patterns to search through and alter HTML and CSS.
by Marco Bertschi
A walk-through on how a Key-Value pair can be parsed using a PERL-compatible regex engine
by Marco Bertschi
A quick overview why you should abandon Qt's QRegExp class and move on to use QRegularExpression
by Marijan Nikic
Regex that can be used for parsing Cron Expressions
by Brian C Hart
Example of how to use the caret (^) in Regexes that have specific matching requirements
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 Henryk Filipowicz
A class to read and parse reg files
by Bryian Tan
How to extract the text from a hyperlink and preserve other HTML tags
by Bryian Tan
Regular Expression to validate the file path and extension and it is compatible with JavaScript and ASP.NET
by Hiren solanki
Remove HTML and get a plain text from inside
by PIEBALDconsult
How about loading it into an XmlDocument and getting the InnerText? (Provided the HTML is well-formed XML, of course.)
by 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...
by 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...
by 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)....
by 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?
by Joezer BH
A simple regex that replaces ALL the illegal filename or path chars
by Brad Joss
SQL CLR Functions for Zip Compression and Regular Expression evaluations
by Artur Ampilogov
Tip for testing numeric inputs with special Unicode symbols.
by santosh poojari
To remove or replace multiple special character from string using sql queries.
by Marco Bertschi
A short Reference on how you can validate a registry-formatted GUID with a regular expression
by 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.