91 regular expressions found in this category!
Displaying page
of
pages;
Items to
| Title |
Test
Details
Pattern Title
|
| Expression |
(NOT)?(\s*\(*)\s*(\w+)\s*(=|<>|<|>|LIKE|IN)\s*(\(([^\)]*)\)|'([^']*)'|(-?\d*\.?\d+))(\s*\)*\s*)(AND|OR)? |
| Description |
Heres my sql clause parser regexp for recordset filtering. Does recursive query parsing all by its self. Only problem I cant figure is how to match comma separated lists of quoted strings. Tell me if you figure out how!
The unicodes in the re was put in by the entry form please replace them with their ascii equivalents to use it. |
| Matches |
Aeroplane LIKE 767 | Movie LIKE 'Star' AND NOT Movie LIKE 'Trek' | Number IN (1,2,3,4,5) |
| Non-Matches |
Hello there | A=EXCELLENT OR | B!=POOR |
| Author |
Rating:
Joseph Warwick
|
| 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:
Jerry Schmersahl
|
| 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:
Eli Robillard
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^([\s\S]){1,20}([\s\.]) |
| Description |
This pattern returns as much of the first x characters of a string as full words or sentences as a match, where x is currently 20. Change x to adjust the length supported in your database field.
I'm currently using this within a string shortening utility to shrink large text regions to word/sentance-boundary elements and appending an ellipsis as a text continuator. |
| Matches |
Any text of any length | ...but will only 'match' the first 20 characters at a period or space. |
| Non-Matches |
N/A |
| Author |
Rating:
Shawn Hall
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(?!^(PRN|AUX|CLOCK\$|NUL|CON|COM\d|LPT\d|\..*)(\..+)?$)[^\x00-\x1f\\?*<>:\;|\"/]+$ |
| Description |
Additional checks for <> and " characters |
| Matches |
abc |
| Non-Matches |
PRN |
| Author |
Rating:
Rahul Pandit
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,15})$ |
| Description |
I built this expression to test a string in ASP for valid username and password constraints. It can be adapted for any number of scenerios. For instance in this case, we needed to ensure the username someone wanted was not all numbers or all letters and was 6-15 characters in length with no special characters. This expression tests negatively for all number cases, then all letter cases, and lastly tests for only alphanumeric characters in the required range. In other words: the match must be alphanumeric with at least one number, one letter, and be between 6-15 character in length. |
| Matches |
C2dfeed | sporttrak1 | 11223a |
| Non-Matches |
pookie | d34_fff | 123456 |
| Author |
Rating:
Pete Lindquist
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(^|\s)(00[1-9]|0[1-9]0|0[1-9][1-9]|[1-6]\d{2}|7[0-6]\d|77[0-2])(-?|[\. ])([1-9]0|0[1-9]|[1-9][1-9])\3(\d{3}[1-9]|[1-9]\d{3}|\d[1-9]\d{2}|\d{2}[1-9]\d)($|\s|[;:,!\.\?]) |
| Description |
Incorporated other people's examples; removed extraneous parenthesis on 10/7/04. Currently the SSA site says 772 is the highest AREA number generated (http://www.ssa.gov/employer/highgroup.txt). Old expression was: (^|\s)\d{3}(-?|[\. ])\d{2}\2\d{4}($|\s|[;:,!\.\?]). Looks for either the beginning of a line or whitespace before the beginning of the social security number, then either zero or one hyphen OR one of a period or space, then uses the \3 to reference the value returned in the parenthesis that includes the -?|[\. ] (basically says if the first dash, period, or space is there, then the second one is required; and if the first dash, period, or space is not there, then the second one can't be either), and finally looks for the end of a line, whitespace, or punctuation characters after the social security number. |
| Matches |
123-45-6789 | 123 45 6789 | 123456789 |
| Non-Matches |
12345-67-890123 | 1234-56-7890 | 123-45-78901 |
| Author |
Rating:
Dennis Flynn
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,15}$ |
| Description |
Password matching expression. Password must be at least 8 characters, no more than 15 characters, and must include at least one upper case letter, one lower case letter, and one numeric digit. |
| Matches |
aaaa1234AAAA | 12aaAA12 | aaaaa12345AAAAA |
| Non-Matches |
aaaaa123456AAAAA | 12aaAA1 | 12aaaa12 |
| Author |
Rating:
Jeff U
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(\d{6}[-\s]?\d{12})|(\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4}) |
| Description |
Credit card validator
Works for switch card numbers too
Switch card bit is (\d{6}[-\s]?\d{12})
Credit card bit is (\d{4}[-\s]?\d{4}[-\s]?\d{4}[-\s]?\d{4})
I use this as a client side test before running a more comprehensive server side check. |
| Matches |
5111 1111 1111 11118 | 1234123412341324 | 123456 123456789012 |
| Non-Matches |
511a 1111 1111 11118 |
| Author |
Rating:
Joe Gass
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[\.\wæøå-]+@([a-zæøå0-9]+([\.-]{0,1}[a-zæøå0-9]+|[a-zæøå0-9]?))+\.[a-z]{2,6}$ |
| Description |
Well it pretty much accepts all kinds of users, about the domain i didn't write it special for any TLD so there's no length defined, ohh and it accepts some IDN stuff |
| Matches |
afdaas-ddas----asddas____...@asd.asd.asd.asd.asd.com | a@a.aa | .@microsoft.sun.apple.com |
| Non-Matches |
aaaaaaa@.-com | aaaaaaa@adf.-com | aaaaaaa@ |
| Author |
Rating:
Andreas Næsager
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(?=.*\d)(?=.*[a-zA-Z])(?!.*[\W_\x7B-\xFF]).{6,15}$ |
| Description |
Password validator
Requires 6-20 characters including at least 1 upper or lower alpha, and 1 digit.
It should disallow just about everything else, inluding extended characters.
|
| Matches |
abc123 | BA99342bob | 1232z123311 |
| Non-Matches |
abcdef | 123456 | 123'ABC |
| Author |
Rating:
Tim Conama
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^([A-Z]{3}\s?(\d{3}|\d{2}|d{1})\s?[A-Z])|([A-Z]\s?(\d{3}|\d{2}|\d{1})\s?[A-Z]{3})|(([A-HK-PRSVWY][A-HJ-PR-Y])\s?([0][2-9]|[1-9][0-9])\s?[A-HJ-PR-Z]{3})$ |
| Description |
UK vehicle registration system. This is the obvious combination of two previous expressions posted here, to merge the older system with the current system. |
| Matches |
ABC 123 A | A 123 ABC | AB 12 ABC |
| Non-Matches |
AB 123 C | A 123 AB | AB 12 AB |
| Author |
Rating:
Amos Hurd
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(.)\1{2,} |
| Description |
matches any string with characters repeated more than twice, sometimes used as fake input |
| Matches |
aaaeee | ???????? | gooogle |
| Non-Matches |
google | booboo |
| Author |
Rating:
Bernard Martin-Rabaud
|
| 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:
Michael Ash
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(?<FirstName>[A-Z]\.?\w*\-?[A-Z]?\w*)\s?(?<MiddleName>[A-Z]\w*|[A-Z]?\.?)\s?(?<LastName>[A-Z]\w*\-?[A-Z]?\w*)(?:,\s|)(?<Suffix>Jr\.|Sr\.|IV|III|II|) |
| Description |
A regex that attempts to accurately parse the elements from a proper name where the format is in <<First, Last>> order or some permutation of that order. Critiques and suggestions for improvement are welcome. |
| Matches |
David F Walker | J. S. Smith, Jr. | Catherine Zeta-Jones |
| Non-Matches |
oscar peterson |
| Author |
Rating:
David Walker
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^[{|\(]?[0-9a-fA-F]{8}[-]?([0-9a-fA-F]{4}[-]?){3}[0-9a-fA-F]{12}[\)|}]?$ |
| Description |
Specifier Format of Guid Values that this RegEx supports: 32 digits: [xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx] 32 digits separated by hyphens: [xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx] 32 digits separated by hyphens, enclosed in brackets: [{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}] 32 digits separated by hyphens, enclosed in parentheses: [(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)] |
| Matches |
914D226A-2F5B-4944-934D-96BBE6571977 | {914D226A-2F5B-4944-934D-96BBE6571977} |
| Non-Matches |
914D226A-2F5B-4944-XXXX-96BBE6571977 | {914D226A-2F5B-4944-XXXX-96BBE6571977} |
| Author |
Rating:
Nicholas Berardi
|
| Title |
Test
Details
Pattern Title
|
| Expression |
[v,V,(\\/)](\W|)[i,I,1,l,L](\W|)[a,A,@,(\/\\)](\W|)[g,G](\W|)[r,R](\W|)[a,A,@,(\/\\))] |
| Description |
Spam trap
Catches many and many way to write viagra (replacing letters with similar chars, spacing chars with one space, etc). |
| Matches |
Viagra | v1@G R /\ | \/iagr@ |
| Non-Matches |
viaagra | vi agra | v1 gra |
| Author |
Rating:
Sante Boscolo
|
| Title |
Test
Details
Word Break
|
| Expression |
^(?:[ -~]{10,25}(?:$|(?:[\w!?.])\s)) |
| Description |
Word Break. This regex can be used to break a long line of text on a full word. The qualifiers specify the minimum and maximum number of character allow before the break and can be changed according to your need. Blogge about this here http://regexadvice.com/blogs/mash/archive/2005/02/09/324.aspx |
| Matches |
This is just a simple sample |
| Non-Matches |
A sample |
| Author |
Rating:
Michael Ash
|
| Title |
Test
Details
Pattern Title
|
| Expression |
(\S+)\x20{2,}(?=\S+) |
| Description |
Trim Inside. This pattern can be used with a replace value of "$1 " to remove multiple consecutive spaces between characters and replace with a single space. Trailing and leading spaces are NOT altered. |
| Matches |
Too Many spaces. |
| Non-Matches |
No extra spaces | No Extra spaces Inside |
| Author |
Rating:
Michael Ash
|
| Title |
Test
Details
Pattern Title
|
| Expression |
^(?=[^\d_].*?\d)\w(\w|[!@#$%]){7,20} |
| Description |
This regex can be used to restrict passwords to a length of 8 to 20 aplhanumeric characters and select special characters. The password also can not start with a digit, underscore or special character and must contain at least one digit. |
| Matches |
password1 | pa$$word2 | pa!@#$%3 |
| Non-Matches |
password | 1stpassword | $password# |
| Author |
Rating:
Michael Ash
|
Displaying page
of
pages;
Items to