How it works
- Enter your pattern and flags.
- Paste the text to test.
- Review the matches, groups and the explanation.
Why use it
- Live highlighting of matches.
- Capture groups and named groups.
- Replacement preview.
- Timeout guard against catastrophic backtracking.
Testing regular expressions: flags, groups and safe patterns
Write, test and understand
Type a pattern and some test text, and every match is highlighted as you type, with a list of matches and the text each group captured. The Explain tab breaks the pattern into its parts in plain words, which is the quickest way to understand a pattern copied from somewhere else. Examples for common jobs, such as email addresses, URLs, IPv4 addresses, ISO dates, hex colours, UUIDs and phone numbers, give a starting point.
The flags
| Flag | Name | Effect |
|---|---|---|
g | global | Find every match, not only the first |
i | ignore case | A and a are the same |
m | multiline | ^ and $ match at the start and end of every line |
s | dot all | . also matches line breaks |
u | unicode | Treats emoji and other characters as one; enables \p{L} and friends |
v | unicode sets | Like u, plus set operations inside classes |
y | sticky | Matches only exactly where the last match ended |
For text in other languages, use u with Unicode properties: \p{L}+ matches a word in any alphabet, where [a-zA-Z]+ would stop at the first accent.
Groups and replacements
Parentheses capture parts of a match. Name them with (?<year>\d{4}) and refer to them in a replacement as $<year>; numbered groups are $1, $2 and so on, the whole match is $&, and a literal dollar sign is $$. The Replace tab shows the result on your test text, which makes it safe to try a search and replace before running it on real files. For example, (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) with $<day>/$<month>/$<year> turns 2026-10-12 into 12/10/2026.
Patterns that freeze
Some patterns take exponentially longer as the text grows, a problem called catastrophic backtracking. (a+)+$ on a long line of a's followed by one other letter is the classic case: each extra letter doubles the work. In a server, such a pattern can be used to stall it with a single crafted input. The tester runs patterns in a background worker and stops any that run longer than 1.5 seconds, telling you instead of freezing the tab. If that happens, look for nested repetition such as (x+)+ or (x*)* and rewrite it.
Engines differ
This is the JavaScript engine of your browser. Most syntax is shared with Python, Java, PHP and .NET, but not all: lookbehind, possessive quantifiers, named group syntax and Unicode classes vary between them. Test in the language you will use before relying on a pattern in production.
If something goes wrong
- The pattern shows an error. A bracket or parenthesis is not closed, or a special character needs a backslash, such as
\.for a literal dot. - Only the first match is found. Switch on the g flag.
- `^` and `$` match only once. Switch on the m flag to match at every line.
Questions and answers
Which regex flavor is used?
JavaScript, as implemented by your browser.
What if my pattern hangs?
Matching runs in a worker with a 1.5 second limit, so the page stays responsive and you get a warning.
Is my text uploaded?
No.