Write a JavaScript pattern, inspect every match, preview a substitution, and read a token-by-token explanation. Everything runs in this tab.
Raw pattern without / delimiters. Native RegExp is the authority.
Shortcut
CtrlEnter74 characters
Text the pattern runs against. It stays in this browser tab.
Docs: https://developer.mozilla.org/ API: http://localhost:3000/api/health
Workspace cleared
Restore the bundled example, or type a pattern and sample text to begin. An empty pattern with sample text is still a valid regular expression.
Uses native replacement tokens. An empty replacement deletes matches.
$& match · $1 group · $<name> name · $$ dollar ·
Substitution output appears after an evaluation.
Waiting for the first evaluation.
abcMatches the literal characters in sequence.
/abc/.test("abc").Matches any character except a line terminator unless the s flag is set.
/a.c/.test("abc")\{ \} \[ \] \( \)Escapes a metacharacter so it matches literally.
/\(\d+\)/.test("(42)")[abc]Matches one character from the listed set.
/[abc]/.test("b")[^abc]Matches one character that is not in the listed set.
/[^abc]/.test("z")[a-z]Matches one character in the inclusive range.
/[a-z]/.test("m")[\dA-F]Matches a digit or a letter from A through F.
/[\dA-F]/.test("C")[\w&&[^_]]Unicode sets mode: matches characters in both operands.
/[\w&&[^_]]/v.test("a")[\w--\d]Unicode sets mode: matches the left operand minus the right.
/[\w--\d]/v.test("a")\d \DMatches a digit, or a non-digit with the capital letter.
/\d+/.test("123")\w \WMatches a word character, or a non-word character.
/\w+/.test("name_1")\s \SMatches whitespace, or non-whitespace.
/\s+/.test(" \t")\p{Letter} \P{Letter}Matches a Unicode property, or its inverse. Requires the u or v flag.
/\p{Letter}+/u.test("abc")(...)Groups the pattern and captures the matched text.
/(ab)+/.exec("abab")(?:...)Groups the pattern without capturing it.
/(?:ab)+/.exec("abab")(?<name>...)Captures the match under a readable name.
/(?<year>\d{4})/.exec("2026")(?i:...)Applies inline flags to this group only.
/(?i:abc)/.test("ABC")^Matches at the start of the input, or of a line with the m flag.
/^abc/.test("abc")$Matches at the end of the input, or of a line with the m flag.
/abc$/.test("abc")\b \BMatches a word boundary, or a non-word boundary.
/\bcat\b/.test("a cat")(?=...)Positive lookahead: the following text must match without consuming it.
/\d+(?=px)/.test("12px")(?!...)Negative lookahead: the following text must not match.
/\d+(?!px)/.test("12em")(?<=...)Positive lookbehind: the preceding text must match without consuming it.
/(?<=\$)\d+/.exec("$42")(?<!...)Negative lookbehind: the preceding text must not match.
/(?<!\$)\d+/.exec("42")*Zero or more repetitions.
/ab*/.test("a")+One or more repetitions.
/ab+/.test("abb")?Zero or one repetition.
/ab?/.test("a"){3}Exactly three repetitions.
/a{3}/.test("aaa"){2,}At least two repetitions.
/a{2,}/.test("aaa"){2,4}Between two and four repetitions.
/a{2,4}/.test("aaa")*? +? ??Makes the quantifier lazy, preferring the fewest repetitions.
/<.+?>/.exec("<a><b>")\n \r \tMatches a line feed, carriage return, or tab.
/a\tb/.test("a\tb")\xhhMatches the character with a two-digit hexadecimal code.
/\x41/.test("A")\uHHHHMatches the character with a four-digit UTF-16 code.
/\u0041/.test("A")\u{1F600}Matches a Unicode code point. Requires the u or v flag.
/\u{1F600}/u.test("😀")\cXMatches the control character for the letter.
/\cA/.test("\u0001")\0Matches the null character, when not followed by a digit.
/\0/.test("\u0000")\1Matches the same text as an earlier numbered capture.
/(a)\1/.test("aa")\k<name>Matches the same text as an earlier named capture.
/(?<x>a)\k<x>/.test("aa")dInclude start and end indices for the match and its captures.
/a/d.exec("a")gFind every match instead of only the first.
"a a".match(/a/g)iIgnore letter case.
/abc/i.test("ABC")mMake ^ and $ match at line breaks.
/^b/m.test("a\nb")sLet . match line terminators too.
/a.b/s.test("a\nb")uEnable full Unicode matching. Cannot combine with v.
/\u{1F600}/u.test("😀")vEnable Unicode set notation. Cannot combine with u.
/[\w--\d]/v.test("a")yMatch only at the current position, without searching ahead.
/a/y.test("a")$$Inserts a literal dollar sign.
"a".replace(/a/, "$$")$&Inserts the whole matched text.
"cat".replace(/cat/, "[$&]")$`Inserts the text before the match.
"cat".replace(/cat/, "$`")$'Inserts the text after the match.
"cat".replace(/cat/, "$'")$1Inserts the text of a numbered capture.
"2026-11".replace(/(\d+)-(\d+)/, "$2/$1")$<name>Inserts the text of a named capture.
"2026-11".replace(/(?<year>\d+)-(?<month>\d+)/, "$<month>/$<year>")