Good to know
Which rules apply
Patterns run with the JavaScript engine in your browser, following the ECMAScript RegExp rules. Most everyday syntax is the same in Python, PHP, Java and .NET, but lookbehind, named groups, possessive quantifiers and flag letters differ between engines, so test in your own language too.
Quick reference
| Write | Matches |
|---|---|
\d | a digit 0–9 |
\w | a letter, digit or underscore (ASCII only) |
\s | a space, tab or line break |
\b | the edge of a word |
[a-f] | one character in the set |
x{2,4} | x, two to four times |
(…) / (?<name>…) | a numbered or named group |
a|b | a or b |
A worked example
Pattern (\d{4})-(\d{2})-(\d{2}) on the text Due 2026-03-14 finds one match, 2026-03-14, at index 4, with groups $1 = 2026, $2 = 03 and $3 = 14. The replacement $3/$2/$1 turns the text into Due 14/03/2026. A named group is written as Other replacement tokens: . Other replacement tokens: $<name>Other replacement tokens: is the whole match and $&$$ is a dollar sign.
Flags that change results
- Without g, only the first match is found and only the first is replaced.
- m makes
^and$match at every line, not just the start and end of the text. - u treats an emoji as one character instead of two halves, and allows
\p{L}for letters in any script.
Slow patterns are stopped
Nested repeats such as (a+)+$ can make the engine try billions of paths on text that almost matches. Your pattern runs in a background worker, and if it takes longer than 1.5 seconds it is stopped so the page stays usable. Up to 1,000 matches are found, and the details list shows the first 200.