Developer tools
Regex tester
Type a regular expression and a test string to see matches highlighted live, with capture groups, every JavaScript flag, and a replace preview. Everything runs in your browser - nothing is uploaded.
Matches
Regex cheatsheet (JavaScript)
Anchors
- ^
- start of string (line with m)
- $
- end of string (line with m)
- \b
- word boundary
- \B
- non-word boundary
Character classes
- .
- any char (not newline)
- \d \D
- digit / non-digit
- \w \W
- word / non-word char
- \s \S
- whitespace / non-whitespace
- [abc]
- any of a, b, c
- [^abc]
- none of a, b, c
- [a-z]
- range a to z
Quantifiers
- *
- 0 or more
- +
- 1 or more
- ?
- 0 or 1 (optional)
- {n}
- exactly n
- {n,}
- n or more
- {n,m}
- between n and m
- *? +?
- lazy (as few as possible)
Groups and lookaround
- (...)
- capture group
- (?:...)
- non-capturing group
- (?<name>...)
- named capture group
- a|b
- match a or b
- (?=...)
- lookahead
- (?!...)
- negative lookahead
- (?<=...)
- lookbehind
- (?<!...)
- negative lookbehind
- \1
- backreference to group 1
Flags
- g
- find all matches
- i
- case-insensitive
- m
- ^ and $ match per line
- s
- dot matches newline
- u
- full unicode
- y
- sticky (from lastIndex)
Escapes
- \. \\ \*
- literal . \ *
- \t \n \r
- tab, newline, return
- \uFFFF
- char by 4-digit code
- \u{1F600}
- code point (u flag)
- \xFF
- char by 2-digit hex
How it works
Type a regular expression in the pattern field and your sample text below, and every match is highlighted live as you type. The match list shows each match with its position and its capture groups - both numbered groups and named ones - so you can see exactly what your pattern is capturing rather than guessing. Toggle the flags g, i, m, s, u, and y on or off, and an invalid pattern shows a clear error instead of failing silently.
This tester uses the regular expression engine built into your browser, so the syntax is JavaScript (ECMAScript) regex - the same flavour you would use in a .js file, which differs in places from PCRE, Python, or Java. Switch to the Replace tab to preview a substitution, using $1 or $<name> to reference captures, and use the built-in cheatsheet as a quick reminder of the common tokens. Everything runs in your browser, so the pattern and text you test are never uploaded, logged, or stored.
Example. Test the pattern (?<year>\d{4})-(\d{2}) against 2024-06 and 1999-12 with the g flag on: both dates highlight, and each match lists the named group year and the numbered group 2 (the month). On the Replace tab, $<year>/$2 rewrites them as 2024/06 and 1999/12.
FAQ
Which regex flavour does this use?
It uses your browser native RegExp, which is JavaScript (ECMAScript) regular expressions. That covers the common syntax - character classes, quantifiers, groups, lookahead, lookbehind, and named groups - but it is not PCRE, so a few constructs from Perl, Python, or PHP (such as possessive quantifiers or recursion) are not supported. The cheatsheet describes the tokens that work here.
What do the flags g, i, m, s, u, and y mean?
g (global) finds every match instead of just the first; i makes matching case-insensitive; m (multiline) lets ^ and $ match at line breaks; s (dotAll) lets the dot match newlines; u (unicode) enables full Unicode and \u{...} escapes; y (sticky) anchors each match to the position where the previous one ended. Turn the global flag on to highlight all matches at once.
How are capture groups shown?
For every match, the list shows the full match plus each capture group. Numbered groups appear in order as $1, $2, and so on, and named groups created with (?<name>...) are listed by name. A group that did not participate in the match is shown as not captured, which helps when you are debugging optional or alternated groups.
Is my pattern or text sent anywhere?
No. Matching and replacing run entirely in your browser using the built-in engine. Nothing you type into the pattern, the test string, or the replacement is uploaded, logged, or stored, so it is safe to test against private or sensitive data.