About the Regex Tester tool
Regular expressions are powerful but notoriously hard to get right on the first try. This regex tester lets you build a pattern and see immediately what it matches in your own sample text. Every match is highlighted in place, and a detailed list shows each match with its position, its numbered and named capture groups, and the start and end index of every group.
The tester uses your browser’s JavaScript regex engine, so results are exactly what you will get in JavaScript, TypeScript and Node.js code. All six flags are available as checkboxes: g (global), i (ignore case), m (multiline), s (dot matches newline), u (Unicode) and y (sticky). Type a replacement string to preview the output of String.replace, including $1 and $<name> group references. If the pattern is invalid, the browser’s error message is shown instead of a crash, and patterns run in a background worker with a time limit, so a pattern with catastrophic backtracking is stopped instead of freezing the page.
A clickable cheat sheet next to the tester reminds you of character classes, anchors, quantifiers and lookarounds. Everything runs locally; your test data is never uploaded.
How to use Regex Tester
- Type your pattern into the “Regular expression” box, or click “Load sample” to see an example.
- Tick the flags you need: g, i, m, s, u or y.
- Paste the text to search into “Test string” and watch matches highlight on the right.
- Review “Match details” for indices and capture groups; use “Copy JSON” or “Download” to save them.
- Optionally type a “Replace with” value to preview the replaced text, then click “Copy result”.
Features
Live highlighting
Matches are highlighted safely in your text as you type, including zero-length matches.
Groups and indices
See numbered and named capture groups with their exact start and end positions.
All JavaScript flags
Toggle g, i, m, s, u and y and see the effect instantly.
Replace preview
Test replacement strings with $1, $<name> and $& before using them in code.
Freeze protection
Patterns run in a worker with a 1.5 second limit, so runaway backtracking cannot lock the page.
Built-in cheat sheet
Click common tokens to insert them into your pattern.
When to use it
- Build validation patterns for email addresses, phone numbers, PIN codes or PAN numbers.
- Extract IDs, dates or amounts from log lines and exported text.
- Test search-and-replace patterns before running them across a codebase.
- Debug why an existing regex matches too much or too little.
- Learn regular expressions by experimenting with the cheat-sheet tokens.
Frequently asked questions
Which regex flavour does this tester use?
It uses the JavaScript (ECMAScript) engine built into your browser. Most syntax is shared with PCRE, Python and Java, but features like possessive quantifiers or \A anchors are not supported in JavaScript.
Why is only one match found?
Without the g (global) flag, JavaScript stops after the first match. Tick g to find all matches.
How do I use named groups in the replacement?
Define a group as (?<name>...) and refer to it as $<name> in the “Replace with” box. Numbered groups use $1, $2 and so on.
What does the “took too long” error mean?
The pattern needed more than 1.5 seconds, usually because of nested quantifiers like (a+)+ that cause catastrophic backtracking. Make the pattern more specific.
Is there a limit on the number of matches?
The first 1,000 matches are listed and highlighted, which keeps the page responsive on large inputs.
Is my text uploaded anywhere?
No. Matching runs in a worker inside your own browser.