Regex Tester
Test a regular expression against text with highlighted matches and capture groups.
Private by design. Your input never leaves this browser. Conversions run locally on your device.
What this tool handles
- Matches or replaces, with the g, i, m, s, u, v, y and d flags.
- Shows every match with its index and its capture groups.
- The pattern runs in a Web Worker that is killed after 750 ms, so catastrophic backtracking cannot freeze the tab.
- Replacement supports $1, $2 and named group references.
Example
Test string
ERROR order=8821 status=timeout
WARN order=8822 status=retry
Matches
[
{
"index": 0,
"end": 16,
"match": "ERROR order=8821",
"groups": [
{
"name": "level",
"value": "ERROR",
"index": 0
},
{
"name": "id",
"value": "8821",
"index": 12
}
]
},
{
"index": 32,
"end": 47,
"match": "WARN order=8822",
"groups": [
{
"name": "level",
"value": "WARN",
"index": 32
},
{
"name": "id",
"value": "8822",
"index": 43
}
]
}
]
When you would use it
- Building a log-parsing pattern — Paste two or three real log lines and grow the pattern one field at a time. The highlighted copy of the input shows which characters each match actually consumed, so a greedy quantifier that ran past a field boundary is visible rather than guessed at.
- Checking a validation rule — Put the strings the rule must accept and the ones it must reject into a single block, then read off which get highlighted — testing only the accepted cases is how an over-permissive rule ships.
- Naming capture groups — Write (?<level>ERROR|WARN) and the results table labels that column level instead of 1, matching what match.groups gives you in code. A group that took no part in a match is listed as (no match).
- Reproducing a ReDoS report — Paste the suspect pattern together with the attack string: if the run is cut short, that pattern really does backtrack catastrophically on that input. Nested quantifiers such as (a+)+ are the usual cause.
Common questions
Which regex flavour does this use?
The browser's own ECMAScript engine, through the RegExp constructor. Constructs that exist only in PCRE — atomic groups, possessive quantifiers, recursion — are not available here.
Do I write the pattern with slashes, like /foo/g?
No. The pattern field takes the body of the expression alone and flags are a separate control, so a leading and trailing slash would be matched as literal characters.
Why does it find only one match?
Without the g flag a JavaScript regular expression returns the first match and stops — that is engine behaviour, not a limit of the tool. Add g to the flags field to find them all.
How many matches does it list?
Up to 1000, after which the list is cut and the summary is marked truncated. Find and replace is not capped the same way: every occurrence is replaced, and the reported count is exact up to 100,000.
Related tools
- Case Converter — Convert text between camelCase, snake_case, kebab-case and six more styles.
- Diff Checker — Compare two texts or two JSON documents line by line or word by word.