Skip to content

Regex Tester

Test a JavaScript regular expression against your text in the browser. Enter a pattern and optional flags, then inspect whether it matched, the match indexes, matched text, positional and named capture groups, and multiple matches with the g flag. Evaluation runs locally in a temporary browser worker — your pattern and text are not sent to an AI model or server.

The JavaScript regular-expression source, without /…/ delimiters. An empty pattern is valid.
Optional JavaScript flags: d, g, i, m, s, u, v, y (as supported by your browser).
The text to test the pattern against. Processed locally in your browser.

How the Regex Tester works

Enter a JavaScript regular-expression pattern, optional flags, and some test text, then run it. PocketSpry evaluates the pattern locally and shows whether it matched, the match indexes, the matched text, and any positional or named capture groups. With the g flag it lists multiple matches. Nothing is uploaded — evaluation runs in a temporary browser worker on your device.

JavaScript regular expressions

This tool uses your browser’s JavaScript RegExp engine, not PCRE, Python, Ruby, Java, or .NET regex. Many constructs look the same across engines, but the details differ, so results reflect JavaScript semantics. Newer flags such as v depend on your browser’s engine support.

Pattern and flags are separate

Enter the pattern source in the Pattern field — for example \bword\b — and put flags such as gi in the Flags field. Do not wrap the pattern in /…/ delimiters: any slashes you type are treated as part of the regular-expression source, exactly as with the RegExp constructor. The g flag is never added automatically; without it, only the first match is reported.

Match indexes are UTF-16 offsets

Reported indexes are JavaScript string offsets (UTF-16 code units), and the end index is exclusive. Because some characters — many emoji, for example — occupy two code units, a single emoji spans two positions. These are not code-point or grapheme indexes.

Why regex testing has a time limit

Some regular expressions can take a very long time to evaluate because of backtracking. PocketSpry runs each test in an isolated browser worker and stops evaluations that exceed its execution budget so the page stays responsive. A timeout does not prove a pattern is malicious — it only means the evaluation exceeded the allotted time; try simplifying the pattern or shortening the test text.

Frequently asked questions

What regex flavor does this use?
JavaScript RegExp, using your browser’s engine.
Should I include /slashes/ around my regex?
No. Enter the pattern source and put flags in the Flags field. Slashes are treated as pattern text.
Which flags are supported?
JavaScript flags d, g, i, m, s, u, v, and y, where supported by your browser’s engine.
What does the g flag do?
It tells the tester to enumerate multiple matches instead of stopping at the first one.
Does PocketSpry automatically add g?
No. Flags are used exactly as you enter them.
Can an empty regex be tested?
Yes. An empty pattern is valid and matches an empty position.
Can I test against empty text?
Yes. Empty test text is valid input.
Does this support capture groups?
Yes, both positional and named capture groups (named groups where the JavaScript syntax is supported).
Why did my regex time out?
It exceeded PocketSpry’s local execution budget. Simplify the pattern or reduce the test text.
Does a timeout mean my regex is unsafe?
Not necessarily. It only means the evaluation exceeded the allotted time.
What do the match indexes mean?
They are JavaScript UTF-16 string offsets, with the end index exclusive.
Does this support PCRE or Python regex?
No. It uses JavaScript RegExp semantics.
Does this support regex replacement?
Not in v1. This is a tester, not a replacer.
Does PocketSpry upload my pattern or test text?
No. This tester runs entirely in your browser.