News in the Category: Regex Subscribe to the rss of this category.

Total posts: 906 | Sort by Views | Sort by Hits

MSDN Regular Expression Forum

Eric Gunnersons C# Compendium, March 1, 2007
Views: 129,617 | Hits 1,998

There's now an MSDN Regular Expression Forum...

How to extract numbers from string

Sushila Patels Weblog, August 4, 2006
Views: 37,120 | Hits 216

VB.NETShared Function ExtractNumbers(ByVal expr As String) As String  Return String.Join(Nothing, System.Text.RegularExpressions.Regex.Split(expr, "[^\d]")) End FunctionC#static string ...

Regex: Allows only positive numbers, greater than zero

RegexLib.com - Recent Patterns, July 29, 2005
Views: 19,488 | Hits 42

Regex: Allows only positive numbers, greater than zero ********************************************* ^[1-9]+[0-9]*$...

Regex: matches a double number

RegexLib.com - Recent Patterns, December 11, 2005
Views: 13,005 | Hits 49

Regex: matches a double number ********************************************* ^(0|(-(((0|[1-9]\d*)\.\d+)|([1-9]\d*))))$...

Regex: Password filter that matches the NSA Password filter DLL ENPASFILT.DLL. At least 1 smal...

RegexLib.com - Recent Patterns, February 8, 2006
Views: 11,512 | Hits 81

Regex: Password filter that matches the NSA Password filter DLL ENPASFILT.DLL. At least 1 small-case letter At least 1 Capital letter At least 1 digit At least 1 special character Le...

Regex: matches a date in dd/mm/yyyy format

RegexLib.com - Recent Patterns, December 11, 2005
Views: 9,949 | Hits 90

Regex: matches a date in dd/mm/yyyy format ********************************************* ^(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0...

Regex 101 Answer S5 - Strip out any non-letter, non-digit characters

Eric Gunnersons C# Compendium, November 23, 2005
Views: 9,899 | Hits 147

Remove any characters that are not alphanumeric. Answer: To remove these characters, we will first need to match them. We know that to match all alphanumeric characters, we could write: [a-zA-Z0-9] To...

2010's Most Popular Articles

4GuysFromRolla.com Headlines, December 29, 2010
Views: 9,813 | Hits 77

The end of the year is upon us, 2010 is about to be in the books. When closing out a year I like to take a look back at the articles I wrote over the year and see which ones resonated the most with r...

Regex: Query string parser matches and tokenizes each name/value pair for a valid query string.

RegexLib.com - Recent Patterns, August 19, 2005
Views: 9,435 | Hits 233

Regex: Query string parser matches and tokenizes each name/value pair for a valid query string. ********************************************* ...

Regex: Parse html tags to extract tag names and parameters with parameter name/value pairs.

RegexLib.com - Recent Patterns, December 11, 2005
Views: 9,235 | Hits 391

Regex: Parse html tags to extract tag names and parameters with parameter name/value pairs. ********************************************* ...

Regex: Credit Card Validation. Matches Switch/Solo, Visa, MasterCard and Discover in 4-4-4-4/4 4 ...

RegexLib.com - Recent Patterns, August 18, 2005
Views: 8,996 | Hits 144

Regex: Credit Card Validation. Matches Switch/Solo, Visa, MasterCard and Discover in 4-4-4-4/4 4 4 4/4444 format and Amex in 4-6-5/4 6 5/465 format. Includes checks for prefixes, (67 ...

Regex: Gets the image url in an HTML <IMG> tag.

RegexLib.com - Recent Patterns, August 17, 2005
Views: 7,999 | Hits 119

Regex: Gets the image url in an HTML <IMG> tag. ********************************************* <img .+ src[ ]*=[ ]*\"(.+)...

Regex: Very simple (but very useful!) regex to split CSV files. It does not drop the commas - yo...

RegexLib.com - Recent Patterns, August 15, 2005
Views: 7,937 | Hits 129

Regex: Very simple (but very useful!) regex to split CSV files. It does not drop the commas - you have to do that manually. Quotes are dealt with properly and escaped quotes are ign...

Regex: This expression will allow Letters, periods, apostrophe, dashes.

RegexLib.com - Recent Patterns, August 3, 2005
Views: 7,677 | Hits 38

Regex: This expression will allow Letters, periods, apostrophe, dashes. ********************************************* ^([a-zA-Z][a-zA...

Mobile No Validation

RegexLib.com - Recent Patterns, September 14, 2006
Views: 7,593 | Hits 731

This Pattern is to Validate Mobile Number with 10 digit Number and Countrycode as Optional....

Regex: Password with minimum 1 Letter (A-Za-z), 1 Number (0-9) and Special Character (\W). It doe...

RegexLib.com - Recent Patterns, December 14, 2005
Views: 7,183 | Hits 155

Regex: Password with minimum 1 Letter (A-Za-z), 1 Number (0-9) and Special Character (\W). It doesn't matter the charaters position. See the Mathching Examples. Question Write an Ema...

Regex: This regex splits comma or semicolon separated lists of optionally quoted strings. It hand...

RegexLib.com - Recent Patterns, January 25, 2006
Views: 6,538 | Hits 62

Regex: This regex splits comma or semicolon separated lists of optionally quoted strings. It handles quoted delimiters and escaped quotes. Whitespace inside quotes is preserved, outsi...

Multi-format date regex

RegexLib.com - Recent Patterns, May 16, 2007
Views: 6,501 | Hits 605

Another date regex. From year 1600-9999, days in month and leap year checks. Formats include MM-dd-YYYY, dd-MM-yyyy, yyyy-MM-dd, MMM dd,yyyy or dd MMM yyyy. Years are always four digits, months can ...

Custom bi-directional sorting in GridView

mikes web log, February 1, 2006
Views: 6,481 | Hits 1,420

One of the things I like is how as you work with ASP.NET (or anything), your instincts develop a bit and you can figure out how to do stuff with only a few dents in your forehead where you've been ban...

Regex: Validates MS FQDNs. 1) Entire fqdn less than 255 chars. 2) Host and domain names may cont...

RegexLib.com - Recent Patterns, January 11, 2006
Views: 6,240 | Hits 32

Regex: Validates MS FQDNs. 1) Entire fqdn less than 255 chars. 2) Host and domain names may contain an underscore. 3) 1st char can be a number. 4) No part can be all numbers. 5) Al...

Regex: US vehicle VIN numbers for vehicles with GVW < 10k lbs

RegexLib.com - Recent Patterns, July 14, 2005
Views: 6,204 | Hits 80

Regex: US vehicle VIN numbers for vehicles with GVW < 10k lbs ********************************************* ^([A-Z]{3}|\d{3})[A-Z]{...

Extract Literal Text from HTML

RegexLib.com - Recent Patterns, September 3, 2007
Views: 6,055 | Hits 840

This regular expression allows you to extract literal text from an HTML (SGML compliant?) document. i believe it will also work for XML. using code to replace the HTML element you can extract the lite...

Simple function to split camelCase words

Technology and Programming - Speednets Lottery Post Blog, August 30, 2007
Views: 6,048 | Hits 835

The phrase "camel case" is used to describe a common method of naming variables, properties, and methods in a programming language.It is useful for stringing several words together, while ma...

Regex 101 Discussion I4 - remove unprintable characters from a string

Eric Gunnersons C# Compendium, January 23, 2006
Views: 6,047 | Hits 166

Exercise I4 - remove unprintable characters from a string Given an input string, remove all characters that are not printable. -------------- Assuming ASCII - or something like ASCII - non-printing ch...

Type.GetType on generic with one or two arguments

MrDaves (David Yack) Blog!, October 19, 2005
Views: 5,886 | Hits 585

You can add this to the beyond the basics on Generics.  If you wanted to use GetType on a regular class you could just do Type.GetType(“MyNameSpace.MyClass”) and your good to go. ...

FQDN Validation

RegexLib.com - Recent Patterns, April 18, 2007
Views: 5,821 | Hits 233

Validates MS FQDNs. 1) Entire fqdn less than 255 chars. 2) Host and domain names may contain an underscore. 3) 1st char can be a number. 4) No part can be all numbers. 5) Allows any TLD Works in C#. B...

Indian Telephone Number Format

RegexLib.com - Recent Patterns, October 16, 2006
Views: 5,812 | Hits 364

This is a bit strict validation format for a telephone number. It has been tested and used on live server and it works fine without any error. +91 indicates ISD code for India. Numbers inside brackets...

Regex: uri

RegexLib.com - Recent Patterns, February 3, 2006
Views: 5,792 | Hits 29

Regex: uri ********************************************* ((((http[s]?|ftp)[:]//)([a-zA-Z0-9.-]+([:][a-zA-Z0-9.&%$-]+)*@)?[a-zA-Z][...

YYYY-MM-DD HH:MM:SS

RegexLib.com - Recent Patterns, June 30, 2007
Views: 5,775 | Hits 314

SQL datetime format tester YYYY-MM-DD HH:MM:SS...

Get Plain Text From Html (Remove Html Tags)

RegexLib.com - Recent Patterns, October 12, 2008
Views: 5,759 | Hits 120

This Regex Will Remove All Html Tags And Return Simple Plain Text . For Example In C#.NET : Regex.Replace(Html, "]*>", string.Empty);...

Regex: Telephone number validation. Validates a telephone number which contains either 0-9,(,),+,...

RegexLib.com - Recent Patterns, August 18, 2005
Views: 5,605 | Hits 65

Regex: Telephone number validation. Validates a telephone number which contains either 0-9,(,),+,- and space. Let me know if it works for you. :) ****...

Regex: Regular expression to fetch <key-value> pairs from the old-fashioned .ini files. Key...

RegexLib.com - Recent Patterns, December 11, 2005
Views: 5,454 | Hits 80

Regex: Regular expression to fetch <key-value> pairs from the old-fashioned .ini files. Key and Value appears in form of named captures with whitespaces stripped on both ends. ...

Regular expression for validating currency input with sign

RegexLib.com - Recent Patterns, May 21, 2007
Views: 5,194 | Hits 551

This expression is for matching the currency input. The is optional. e.g. 12.12, 12.12, 12.12, 12....

Find IP Address Block Range

RegexLib.com - Recent Patterns, September 3, 2007
Views: 5,014 | Hits 307

This expression matches IP Addresses between 192.168.0.17 - 192.168.0.32 which is a block range of 16 addresses. I created this expression for Google Analytics to filter out hits from our companies of...

Regex 101 Discussion I9 - Count the number of matches.

Eric Gunnersons C# Compendium, March 6, 2006
Views: 4,936 | Hits 211

Regex 101 Exercise I9 - Count the number of matches Given a string like: # # 4 6 # # 7 # 45 # 43 # 65 56 2 # 4345 # # 23   Count how many numbers there are in this string ----- There are a f...

ASP.NET ItemTemplates, EVAL() and embedding dynamic values into controls

Rick Strahls WebLog, April 27, 2006
Views: 4,833 | Hits 487

Dealing with complex Eval() expressions inside of ItemTemplate or other data containers always makes me do a double take. Here are a few observations and thoughts on how to handle and possibly improv...

Regex: International Bank Account Number (IBAN) Sweden. Identify Bank account in Sweden.

RegexLib.com - Recent Patterns, September 9, 2005
Views: 4,634 | Hits 38

Regex: International Bank Account Number (IBAN) Sweden. Identify Bank account in Sweden. ********************************************* ...

Birthday regular expression Dutch

RegexLib.com - Recent Patterns, May 4, 2007
Views: 4,628 | Hits 257

I needed to have a birthday regular expression in dutch format with full year (1900) so i wrote this one....

Regex: parsing a linux ftp list string. result is a list of several groups like : dir (-,l,d) p...

RegexLib.com - Recent Patterns, July 26, 2005
Views: 4,574 | Hits 32

Regex: parsing a linux ftp list string. result is a list of several groups like : dir (-,l,d) permission (lrwxrwxrwx) filecode (any number) owner (what it says - number or text) group...

Splitting Camel Case with RegEx

JonGalloway.ToString(), September 27, 2005
Views: 4,550 | Hits 417

Phil posted some code to Split Pascal/Camel Cased Strings a few days ago. We had an offline discussion on doing this via RegEx. I like the RegEx approach since it's only one line of code: output&nbs...

Regex: Accurate IP address verification... Each numeric part of an IP address must be between ...

RegexLib.com - Recent Patterns, December 29, 2005
Views: 4,520 | Hits 102

Regex: Accurate IP address verification... Each numeric part of an IP address must be between 0 and 255. All patterns I have seen on the net cover this range but they allow leading z...

Date-MM/DD/YYYY MONTH/DATE/YEAR

RegexLib.com - Recent Patterns, April 19, 2007
Views: 4,473 | Hits 225

This regular expressions matches dates in the format MM/DD/YYYY where MM can be 01 to 12, DD can be 01 to 31 and YYYY is always 4 digits long....

Latitude Validation

RegexLib.com - Recent Patterns, October 30, 2006
Views: 4,439 | Hits 397

I was inspired by this regexp - Matches a whole number between 1 and 20 inclusively - because it was doing something I could not find elsewhere so this is how I expanded it to validate lat values...

Split camelCase word

RegexLib.com - Recent Patterns, August 30, 2007
Views: 4,420 | Hits 131

Used with the Regex.Split() function in .NET, this will easily split a camelCase word on the upper case letters, while not dropping any characters. (That makes it different from most split() function...

ICD-10 Code (World Health Organization)

RegexLib.com - Recent Patterns, July 9, 2008
Views: 4,287 | Hits 189

This expression matches ICD-10 code...

URL Validator

RegexLib.com - Recent Patterns, July 27, 2007
Views: 4,284 | Hits 564

A simple but powerful URL validating regex. Will only accept hyper text transfer protocol (http) but can be easily changed to accept others. Accepts multiple subdomains and subdirectories. Even accept...

Match Valid UK Postcode

RegexLib.com - Recent Patterns, March 6, 2007
Views: 4,253 | Hits 367

Validates a complete UK postcode. Returns the two halves in sub-expressions. Supports the following 7 formats: A1 1AA, A11 1AA, A1A 1AA, AA1 1AA, AA11 1AA, AA1A 1AA GIR 0AA (** And the same 7 formats ...

mm/dd/yyyy hh:mm:ss Date Time

RegexLib.com - Recent Patterns, November 11, 2008
Views: 4,217 | Hits 109

I got a regex for date time from here, which had some bugs. so i referred a few regex from this site and created a regex which i tested and didnt find any errors. I will check again and update if requ...

Password Validation

RegexLib.com - Recent Patterns, September 4, 2007
Views: 4,182 | Hits 347

Well, I don't remember where from I got this expression, but I modified it a bit to work with asp.net 2.0's Regular expression validator. This validates if the password has atleast 6 characters, of wh...

UK Postcode

RegexLib.com - Recent Patterns, March 2, 2007
Views: 4,132 | Hits 302

This regex have been created as per the information provided on http://www.govtalk.gov.uk/gdsc/html/noframes/PostCode-2-1-Release.htm. This expression will allow the postcodes with space or without sp...