91 regular expressions found in this category!
Displaying page
of
pages;
Items to
Title |
Test
Details
Parse Comma Delimited Strings
|
Expression |
^(?<field1>[^,]+),(?<field2>[^,]+),(?<field3>[^,]+)$ |
Description |
Example of a regular expression that can be used to parse a comma delimited string into constituent, named sub-strings. Add or remove regex subfield definitions (?<field1>[^,]+) and corresponding delimiting characters in the regular expression as necessary to accommodate the string and subfields you intend to parse. Optionally, rename the subfield names in the regular expression to more meaningful names if you are using the parsed sub-strings in a program. Replace all occurrences of the comma in the regular expression with any required alternative delimiting character. As long as the delimiting character used does not occur naturally in any of the sub-strings, you should be good-to-go. NOTE: To change the delimiter character you must replace all occurrences of the comma in the current regex (of which there are 5) with the new delimiter character. e.g. (?<field1>[^;]+); changes the delimiter character to a semi-colon for the first field. |
Matches |
Fred,Barnie,Wilma | Bob,1/1/2003,222-3333 | 100,200,300 |
Non-Matches |
Fred,Barnie,Wilma,Betty | Bob;1/1/2003;222-3333 | Tom Dick Harry |
Author |
Rating:
Not yet rated.
Jerry Schmersahl
|
Title |
Test
Details
Pattern Title
|
Expression |
^(?!000)(?!666)(?<SSN3>[0-6]\d{2}|7(?:[0-6]\d|7[012]))([- ]?)(?!00)(?<SSN2>\d\d)\1(?!0000)(?<SSN4>\d{4})$ |
Description |
Updated on 3/4/2004 per feedback to additionally exclude SSNs that begin with 666 which, as reported, are also not valid.
Regular expression for validating US Social Security Numbers. Accepts optional hyphens or spaces as formatting characters. Parses the three subfields of the SSN into three named sub-strings (SSN1, SSN2, and SSN3) to facilitate program use. Rejects matches on all zeros for any individual subfield of the Social Security Number. Matches only on those SSNs that fall within the range of numbers currently allocated by the Social Security Administration. |
Matches |
111223333 | 111-22-3333 | 111 22 3333 |
Non-Matches |
111003333 | 111 22-3333 | 666-22-3333 |
Author |
Rating:
Not yet rated.
Jerry Schmersahl
|
Title |
Test
Details
Pattern Title
|
Expression |
(\w(\s)?)+ |
Description |
Used to verify that the string consists of only A-z, 0 - 9 and underscore. Several words allowed, only one space between them. No spaces up front. Hey, I know it's easy, but it was not in the library! Plus, the test option here is not working well all the time. |
Matches |
Test | TesT | tesT9 _test9 |
Non-Matches |
\\\ |
Author |
Rating:
Not yet rated.
Alsu Fifty
|
Title |
Test
Details
ISBN-10
|
Expression |
ISBN\x20(?=.{13}$)\d{1,5}([- ])\d{1,7}\1\d{1,6}\1(\d|X)$ |
Description |
This RE validates the format of an ISBN number |
Matches |
ISBN 0 93028 923 4 | ISBN 1-56389-668-0 | ISBN 1-56389-016-X |
Non-Matches |
123456789X | ISBN 9-87654321-2 | ISBN 123 456-789X |
Author |
Rating:
Not yet rated.
Michael Ash
|
Title |
Test
Details
Pattern Title
|
Expression |
^((Bob)|(John)|(Mary)).*$(?<!White) |
Description |
"Starts with but does not end with."
I needed a pattern to require certain first (and optional middle) names, but to fail for certain last names. So if Bob, John, and Mary are acceptable first names but the White's are always rejected then...
|
Matches |
Bob Jones | John Smith | Mary Jane Smith |
Non-Matches |
Bob White | Mary Doe White | Gina Smith |
Author |
Rating:
Not yet rated.
Eli Robillard
|
Title |
Test
Details
Pattern Title
|
Expression |
^ISBN\s(?=[-0-9xX ]{13}$)(?:[0-9]+[- ]){3}[0-9]*[xX0-9]$ |
Description |
This pattern validates ISBN numbers. I've written a full description about it here: http://regexblogs.com/dneimke/posts/201.aspx |
Matches |
ISBN 90-70002-34-5 | ISBN 90-70002-34-x |
Non-Matches |
ISBN 90-70002-34-5x | ISBN 90-700-02-34-5 |
Author |
Rating:
Not yet rated.
Darren Neimke
|
Displaying page
of
pages;
Items to