91 regular expressions found in this category!
Displaying page
of
pages;
Items to
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 |
^(?=[^\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
|
Title |
Test
Details
Pattern Title
|
Expression |
^((?:4\d{3})|(?:5[1-5]\d{2})|(?:6011)|(?:3[68]\d{2})|(?:30[012345]\d))[ -]?(\d{4})[ -]?(\d{4})[ -]?(\d{4}|3[4,7]\d{13})$ |
Description |
This just a minor mod to Steven Smith's credit card re to accept spaces as separators, as well as return the four parts of the card. [Updated Oct-18-2002 to work with Diners Club/Carte Blanche (prefix must be 36, 38, or 300-305)] |
Matches |
6011567812345678 | 6011 5678 1234 5678 | 6011-5678-1234-5678 |
Non-Matches |
1234567890123456 |
Author |
Rating:
Glenn Carr
|
Title |
Test
Details
Pattern Title
|
Expression |
(\w+)\s+\1 |
Description |
This expression uses a BackReference to find occurrences of the same word twice in a row (separated by a space).
Matches things like 'mandate dated', which may not be desirable. See Sean Carley's update for a better expression for true repeated word matching. |
Matches |
hubba hubba | mandate dated | an annual |
Non-Matches |
may day | gogo | 1212 |
Author |
Rating:
Steven Smith
|
Title |
Test
Details
Pattern Title
|
Expression |
^\d{3}-\d{2}-\d{4}$ |
Description |
This regular expression will match a hyphen-separated Social Security Number (SSN) in the format NNN-NN-NNNN. |
Matches |
333-22-4444 | 123-45-6789 |
Non-Matches |
123456789 | SSN |
Author |
Rating:
Steven Smith
|
Title |
Test
Details
Pattern Title
|
Expression |
^([A-Z]{1}[a-z]{1,})$|^([A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,})$|^([A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,}\040[A-Z]{1}[a-z]{1,})$|^$ |
Description |
Matches up to three alphabet words separated by spaces with first alphabet character of each word uppercase. Also matches empty strings. |
Matches |
Sacramento | San Francisco | San Luis Obispo |
Non-Matches |
SanFrancisco | SanLuisObispo | San francisco |
Author |
Rating:
Don Batchelor
|
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 |
^([1-9]{1}(([0-9])?){2})+(,[0-9]{1}[0-9]{2})*$ |
Description |
Matchs comma delimited numbers. Easily changed to allow for other delimiters. (Edit ",")
Does not allow a leading 0
Does not allow groups of numbers with less than 3 numbers, exculding the first group. |
Matches |
123,123,123,123 | 100,120,000,010,011 | 1,123,123,123 |
Non-Matches |
012,123,123,123 | 12343,1244,4,12 | ,123,123,123 |
Author |
Rating:
Gregory Lyons
|
Title |
Test
Details
Social Security Number
|
Expression |
^(?!000)([0-6]\d{2}|7([0-6]\d|7[012]))([ -]?)(?!00)\d\d\3(?!0000)\d{4}$ |
Description |
This regex validates U.S. social security numbers, within the range of numbers that have been currently allocated. |
Matches |
078-05-1120 | 078 05 1120 | 078051120 |
Non-Matches |
987-65-4320 | 000-00-0000 | (555) 555-5555 |
Author |
Rating:
Michael Ash
|
Title |
Test
Details
Pattern Title
|
Expression |
^[a-zA-Z0-9]+$ |
Description |
it will check for alphanumeric (Alpha Numeric) values. |
Matches |
adad1213 | 1231dfadfa | dfad123dfasdfs |
Non-Matches |
dfa@#12313 | *(*sdfasdfadfd | $fffsdg121ddd#$f1q |
Author |
Rating:
himraj love
|
Title |
Test
Details
Pattern Title
|
Expression |
(script)|(<)|(>)|(%3c)|(%3e)|(SELECT) |(UPDATE) |(INSERT) |(DELETE)|(GRANT) |(REVOKE)|(UNION)|(&lt;)|(&gt;) |
Description |
This Blacklist RegEx is designed to search a user input for any malicious code or SQL injection attempts. |
Matches |
http://www.domain.com/page.asp?param=</script> | https://www.domain.com/page.asp?param=;SELECT |
Non-Matches |
https://www.domain.com/page.asp?param=RealParam |
Author |
Rating:
Shahar Bracha
|
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 |
^(\d{4}-){3}\d{4}$|^(\d{4} ){3}\d{4}$|^\d{16}$ |
Description |
Used to validate Credit Card numbers, Checks if it contains 16 numbers in groups of 4 separated by -, ,or nothing |
Matches |
1111-2323-2312-3434 | 1234343425262837 | 1111 2323 2312 3434 |
Non-Matches |
1111 2323 2312-3434 | 34323423 | 1111-2323-23122-3434 |
Author |
Rating:
Sachin Bhatt
|
Title |
Test
Details
Pattern Title
|
Expression |
foo |
Description |
The "hello world" of regular expressions, this will match any string with an instance of 'foo' in it. |
Matches |
foo |
Non-Matches |
bar |
Author |
Rating:
Steven Smith
|
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 |
^[\.\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 |
|
Non-Matches |
|
Author |
Rating:
Andreas Næsager
|
Title |
Test
Details
Pattern Title
|
Expression |
^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$ |
Description |
Matches major credit cards including:
Visa (length 16, prefix 4), Mastercard (length 16, prefix 51-55), Discover (length 16, prefix 6011), American Express (length 15, prefix 34 or 37). All 16 digit formats accept optional hyphens (-) between each group of four digits. |
Matches |
6011-1111-1111-1111 | 5423-1111-1111-1111 | 341111111111111 |
Non-Matches |
4111-111-111-111 | 3411-1111-1111-111 | Visa |
Author |
Rating:
Steven Smith
|
Title |
Test
Details
Pattern Title
|
Expression |
^([0-9a-fA-F]){8}$ |
Description |
Hex number/string validation method for the Electronic Serial Number(ESN) used in Cellular Phone products. |
Matches |
8ECCA04F | 82E5AAA4 | 82e5aaa4 |
Non-Matches |
8ECCAOF | 82E5AA4 | 82e5aaa45 |
Author |
Rating:
Cliff Wagner
|
Title |
Test
Details
Pattern Title
|
Expression |
^([A-Z|a-z|&]{3}\d{2}((0[1-9]|1[012])(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])(29|30)|(0[13578]|1[02])31)|([02468][048]|[13579][26])0229)(\w{2})([A|a|0-9]{1})$|^([A-Z|a-z]{4}\d{2}((0[1-9]|1[012])(0[1-9]|1\d|2[0-8])|(0[13456789]|1[012])(29|30)|(0[13578]|1[02])31)|([02468][048]|[13579][26])0229)((\w{2})([A|a|0-9]{1})){0,3}$ |
Description |
Registro Federal de Contribuyentes (RFC) , used in Mexico as a unique set of caracters for a person or corporation registration .
Registro Federal de Contribuyentes utilizado en Mexico para el registro en hacienda. |
Matches |
ABCD790419 | ABC790419aa1 | ABCD790419AB1 |
Non-Matches |
AB790419 | A12790419 | ABC791332 |
Author |
Rating:
Leo Hinojosa
|
Displaying page
of
pages;
Items to