Regex Tester for JavaScript and Go (RE2)
Test a regular expression against your text with the JavaScript engine or with Go's RE2 engine, and see every match, capture group and replacement.
Syntax cheat sheet for both engines
| Token | Meaning | JavaScript | Go (RE2) |
|---|---|---|---|
. | Any character except a line break. With the s flag it matches line breaks too. | Yes | Yes |
\d \w \s | A digit, a word character, a white space character. The capitals \D, \W and \S match the opposite. | Yes | Yes |
[abc] [^abc] [a-z] | One character from a set, one character not in the set, one character in a range. | Yes | Yes |
^ $ | Start and end of the text. With the m flag, start and end of every line. | Yes | Yes |
\b \B | A word boundary, and a position that is not a word boundary. | Yes | Yes |
* + ? {2,5} | Zero or more, one or more, zero or one, between 2 and 5 times. Each takes as much as it can. | Yes | Yes |
*? +? ?? {2,5}? | The same quantifiers, taking as little as they can. | Yes | Yes |
(…) (?:…) | A capture group, and a group that only groups. | Yes | Yes |
(?<name>…) | A named capture group. Go accepts this form since version 1.22, and (?P<name>…) in every version. | Yes | Yes |
a|b | Either a or b. | Yes | Yes |
\p{L} \p{Lu} | A Unicode property: any letter, any uppercase letter. JavaScript needs the u flag for it. | Yes | Yes |
(?i) (?s) (?m) | Flags written inside the pattern. In JavaScript, flags are set outside it. | No | Yes |
\A \z | Start and end of the whole text, whatever the m flag says. | No | Yes |
[[:alpha:]] | A POSIX character class inside a set. | No | Yes |
(?=…) (?!…) | Lookahead: what follows must match, or must not match, without being consumed. | Yes | No |
(?<=…) (?<!…) | Lookbehind: what comes before must match, or must not match. | Yes | No |
\1 \k<name> | Backreference: the same text an earlier group matched. | Yes | No |