Regex tester
Write a regular expression and see every match highlighted as you type, with capture groups and replace.
//
Matches
Quick reference
. | Any character except line breaks (all characters with the s flag) |
\d \w \s | Digit, word character, whitespace |
[abc] [^abc] | Any of a, b, c / anything except them |
* + ? {2,5} | 0+, 1+, 0 or 1, between 2 and 5 times |
^ $ | Start and end of input (of each line with m) |
( ) (?:) (?<name>) | Capture group, non-capturing group, named group |
a|b | a or b |
(?=) (?!) | Lookahead, negative lookahead |
Flavour
This tester uses JavaScript's regex engine, the same as browsers and Node.js. Most syntax works the same in Python, Java, PHP and .NET, but details such as lookbehind support and named-group syntax can differ.
Questions
What does the g flag do?
Global: find every match instead of stopping at the first.
How do I use a capture group in the replacement?
Write $1 for the first group, $2 for the second, or $<name> for a named group.