javascript  javascript :: Match

Regular expression validation


Not checked
Social bookmark
Useful? Share this page with others.

del.icio.us Favicon Digg Favicon Email Favicon Google Favicon LinkedIn Favicon Live Favicon Slashdot Favicon StumbleUpon Favicon Technorati Favicon TwitThis Favicon

Pattern Cheatsheet
\wAny "word" character (a-z 0-9 _)
\WAny non "word" character
\sWhitespace (space, tab CRLF)
\SAny non whitepsace character
\dDigits (0-9)
\DAny non digit character
.Any character except newline
n*Zero or more of n
n+One or more of n
n?Zero or one occurrences of n
{n}n occurrences exactly
{n,}At least n occurrences
{,m}At most m occurrences
{n,m}Between n and m occurrences (inclusive)
\bWord boundary
\BNot a word boundary
\AStart of subject
\ZEnd of subject or newline at end
\zEnd of subject
\GFirst matching position in subject
iCase Insensitive
mMultiline mode - ^ and $ match start and end of lines
sDotall - . class includes newline
xExtended– comments and whitespace
epreg_replace(PHP) only – enables evaluation of replacement as PHP code
SExtra analysis of pattern
UPattern is ungreedy
uPattern is treated as UTF-8
^Start of subject (or line in multiline mode)
$End of subject (or line in multiline mode)
[Start character class definition
]End character class definition
|Alternates, eg (a|b) matches a or b
(Start subpattern
)End subpattern
\Escape character
\nnewline
\rcarriage return
\ttab
\xhhcharacter with hex code hh
\dddcharacter with octal code ddd
(?=)Positive look ahead assertion foo(?=bar) matches foo when followed by bar
(?!)Negative look ahead assertion foo(?!bar) matches foo when not followed by bar
(?<=)Positive look behind assertion (?<=foo)bar matches bar when preceded by foo
(?Negative look behind assertion (?
(?>)Once-only subpatterns (?>\d+)bar Performance enhancing when bar not present
(?(x))Conditional subpatterns
(?(3)foo|fu)barMatches foo if 3rd subpattern has matched, fu if not
(?#)Comment (?# Pattern does x y or z)