About this tester
Test JavaScript regular expressions against any text right in your browser. Toggle flags, see every match with its position and capture groups, run a replacement, or split the text by the pattern. Nothing leaves your browser.
Regex cheatsheet
A quick reference for the most useful regex tokens.
.- any character except newline
\d- any digit (0-9)
\w- word character (letters, digits, _)
\s- any whitespace
\D- any non-digit
^- start of input (or line with m)
$- end of input (or line with m)
\b- word boundary
[abc]- any of a, b, or c
[^abc]- anything except a, b, or c
*- zero or more of the previous
+- one or more of the previous
?- zero or one of the previous
{n}- exactly n occurrences
{n,m}- from n to m occurrences
(...)- capturing group
(?:...)- non-capturing group
a|b- match a or b
(?=...)- positive lookahead
(?<=...)- positive lookbehind