RegExLib.com - The first Regular Expression Library on the Web!

Please support RegExLib Sponsors

Sponsors

Browse Expressions by Category

91 regular expressions found in this category!

Expressions in category: Strings

Change page:   |    Displaying page 1 of 5 pages; Items 1 to 20
Title Test Details Any One US ASCII Letter
Expression
^[a-zA-Z]$
Description
Matches any single upper- or lower-case letter.
Matches
a | B | c
Non-Matches
0 | & | AbC
Author Rating: The rating for this expression. 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: The rating for this expression. Steven Smith
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: The rating for this expression. Steven Smith
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: The rating for this expression. Michael Ash
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: The rating for this expression. Pete Lindquist
Title Test Details Pattern Title
Expression
^([30|36|38]{2})([0-9]{12})$
Description
Validate against any diner's club card. All diner club cards start with 30,36, or 38, followed by 12 other numbers.
Matches
30125212365212 | 36125212365212 | 38125212365212
Non-Matches
301252123652121 | 40256631125452 | 361251254125212
Author Rating: The rating for this expression. Jeff Johns
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: The rating for this expression. Glenn Carr
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: The rating for this expression. Shawn Hall
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: The rating for this expression. Don Batchelor
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: The rating for this expression. Sachin Bhatt
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 &lt;&lt;First, Last&gt;&gt; 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: The rating for this expression. David Walker
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: The rating for this expression. Dennis Flynn
Title Test Details Pattern Title
Expression
foo
Description
The &quot;hello world&quot; of regular expressions, this will match any string with an instance of 'foo' in it.
Matches
foo
Non-Matches
bar
Author Rating: The rating for this expression. Steven Smith
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: The rating for this expression. himraj love
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 &quot;,&quot;) 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: The rating for this expression. Gregory Lyons
Title Test Details Pattern Title
Expression
(script)|(&lt;)|(&gt;)|(%3c)|(%3e)|(SELECT) |(UPDATE) |(INSERT) |(DELETE)|(GRANT) |(REVOKE)|(UNION)|(&amp;lt;)|(&amp;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=&lt;/script&gt; | https://www.domain.com/page.asp?param=;SELECT
Non-Matches
https://www.domain.com/page.asp?param=RealParam
Author Rating: The rating for this expression. Shahar Bracha
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: The rating for this expression. Michael Ash
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: The rating for this expression. 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: The rating for this expression. Sante Boscolo
Title Test Details Pattern Title
Expression
^([A-Za-z0-9]\s?)+([,]\s?([A-Za-z0-9]\s?)+)*$
Description
This regular expression can be used to parse a comma delimited string. Leading whitespaces (at the beginning of the entire string) and ending commas are not acceptable. Any combination of letters and numbers with zero or one white space between them are acceptable. Note: To change the delimiter, simply replace the comma in the square brackets to the delimiter of choice.
Matches
123, 4567, 8901 | abc, defghi, jklmn | abc123
Non-Matches
abc123 | abc123, | ,abc123
Author Rating: The rating for this expression. Rehan Azam
Change page:   |    Displaying page 1 of 5 pages; Items 1 to 20

Copyright © 2001-2024, RegexAdvice.com | ASP.NET Tutorials