- iTechFever Tools
- Developer Tools
- Regex Tester
Regex Tester
Type a pattern and your text. Matches are highlighted as you go, with every capture group listed by name or number, and a replacement preview if you need one.
Runs entirely in your browser. Your files are never uploaded.
How to use Regex Tester
- 1Enter your pattern, without the surrounding slashes.
- 2Switch on the flags you need.
- 3Paste the text to test against.
- 4Read the matches, or try a replacement.
A runaway pattern cannot freeze the page
Some patterns take effectively for ever on the wrong input. The classic is (a+)+b against a long run of a characters, where the engine tries every way of splitting the run before giving up. There is no way to interrupt that from inside the page.
So the matching runs in a worker, a separate thread with no access to the page. If it has not answered within a second, the worker is terminated and you are told the pattern took too long. The tab stays usable and your text stays where it was.
Groups, named and numbered
Each match lists its capture groups in order, with the name if the group has one. A group that took part in the match but captured nothing is shown as empty, which is different from a group that was never reached, and that difference is usually the bug.
The flavour is JavaScript's own regular expressions, the same engine your browser uses. Patterns written for PCRE, Python or Go mostly transfer, with the exception of possessive quantifiers and recursion, which JavaScript does not have.
Replacement preview
The replacement field uses JavaScript's own syntax: $1 for a numbered group, $<name> for a named one, $& for the whole match. The result is the entire text with every replacement applied, so you can copy it straight out rather than trusting a sample.
Limits
- JavaScript regular expressions. No possessive quantifiers, no recursion, no inline flag groups.
- The text is limited to 200,000 characters, and 1,000 matches are reported.
- A pattern that takes more than a second is stopped rather than finished.
- Needs Web Workers, which every current browser has, to run a pattern safely.
Frequently asked questions
- Do I include the slashes around the pattern?
- No. Enter the pattern alone and use the flag switches for g, i, m, s and u. Pasting /pattern/g would look for a literal slash at each end.
- Why does my pattern from another language not work?
- This is JavaScript's engine, which has no possessive quantifiers, no recursive patterns and no atomic groups. Lookbehind, named groups and unicode property escapes all work in current browsers.
- What does the timeout mean?
- That your pattern and text together make the engine backtrack enormously. Nested quantifiers like (a+)* are the usual cause. Making the inner part more specific, or anchoring the pattern, normally fixes it.
- Is my text sent to a server to be matched?
- No. Matching happens in a worker thread inside your own browser. Nothing is uploaded, which matters when you are testing a pattern against real log lines or customer data.