Regex Tester
Test regular expressions with real-time matching and group capture.
This Regex Tester runs JavaScript regular expressions against your sample text and highlights every match as you type. It uses the browser's native RegExp engine, so what you see here is exactly how your pattern will behave in JavaScript or TypeScript code. Toggle the g, i, m, s, u, and y flags with checkboxes and watch the result update instantly.
Use it to debug a pattern that almost works, to learn how capture groups and named groups behave, or to validate email, URL, and phone formats before pasting the pattern into your app. Each match shows its position (index) and any captured groups as JSON, and you can copy the full match report with one click. Everything runs locally in your browser, so your patterns and test data never leave your machine.
How to use
- Type or paste your regular expression into the Pattern field (without the surrounding slashes, just the body).
- Turn on the flags you need: g for all matches, i for case-insensitive, m for multiline, s for dotAll, u for unicode, and y for sticky.
- Paste the text you want to test against into the Test String box.
- Read the highlighted matches and the Match Details list, which shows each match's index and any capture groups.
- Click Copy to copy the full match report, then paste the working pattern into your code.
FAQ
- Which regex syntax does this tool use?
- It uses the JavaScript RegExp engine built into your browser, the same one that runs in Node.js and the V8 engine. Features like lookbehind, named capture groups, and unicode property escapes work if your browser supports them. Note that this differs from PCRE, Python, or .NET flavors.
- Why does my pattern only return one match without the g flag?
- Without the global (g) flag, JavaScript stops at the first match. Enable the g checkbox to find every occurrence in the test string and see them all highlighted.
- Do I need to include the slashes or escape them?
- No. Enter only the pattern body, for example \d{4}-\d{2}-\d{2}, without the leading and trailing slashes. The tool adds the slashes and flags for you in the display.
- How do I capture named groups?
- Use the (?<name>...) syntax, for example (?<year>\d{4})-(?<month>\d{2}). Captured groups appear as a JSON object in the Match Details for each match.
- Is my test data sent to a server?
- No. All matching happens locally in your browser using JavaScript. Your pattern and test string are never uploaded, so it is safe to test with sensitive or private data.