test|regex


test your regular expressions online



PATTERN:
TEXT:


Javascript-flavored regex - Processed in the browser, not server-side - Case sensitive - Contact


 

[xyz] Matches any character between the brackets e.g. x, y or z
[^xyz] Matches any character not between the brackets e.g. a, b, 1, +, etc.
[0-9] Matches any digit from 0 to 9 e.g. 0, 1, 2, ...
[^3-7] Matches any character not between the brackets e.g. 2, 8, a, *, etc.
[a-z] Matches any letter from a to z e.g. [a-c] matches a, b and c
(x|y|z) Matches any one of the specified expressions e.g. x or y or z
. Matches a single character except new line or terminator e.g. 2, +, a, etc.
\d Matches a single digit e.g. 0, 1, 2, ...
\D Matches a single non-digit character e.g. a, +, etc.
\w Matches a single word character (e.g. characters except punctuation or spaces)
\W Matches a single non-word character (e.g. the opposite of \w)
\s Matches a whitespace
\S Matches a non-whitespace character
\b Matches the beginning or end of a word e.g. \byz matches yz & xy\b matches xy in xyz
\B Matches anything but the beginning or end of a word e.g. \By matches y in xyz but not in yz
\n Matches new line character
\f Matches a carriage return
\t Matches a tab
\v Matches a vertical tab
\0 Matches NUL (the null character)
\f Matches the form feed character
\x2B Matches the character with the specified hexadecimal ASCII code e.g. \x2B matches +
\053 Matches the character with the specified octal ASCII code e.g. \053 matches +
\u002B Matches the character with the specified hexadecima Unicode e.g. \u002B matches +
x+ Matches strings that contain one or more occurrences e.g. xx holds 2 matches for x but only 1 for x+
x* Matches strings that contain zero or more occurrences e.g. x*l matches l, xl, xxl and so on...
x? Matches strings that contain zero or one occurrences e.g. x?l matches l and xl (but not xxl)
x{N} Matches strings that contain N occurrences of x e.g. x{2} matches xx
x{N,} Matches strings that contain at least N occurrences of x e.g. a{2,} matches aa, aaa and so on...
x{N,M} Matches strings that contain N <= occurrences of x <= M e.g. a{2,3} matches aa and aaa
^x Matches strings beginning with x e.g. ^x has 1 match in xyz but none in abcxyz
x$ Matches strings ending with x e.g. x$ has 1 match in ax but none in axb
?=x Matches strings followed by x (lookahead) e.g. y(?=x) matches yx
?!x Matches strings not followed by x (negative lookahead) e.g. y(?!x) has 2 matches yayxyb