Regex Tester
Write a JavaScript regular expression, choose flags and see every match highlighted, with numbered and named capture groups and match positions. Patterns run in a background worker with a time limit, so a runaway pattern cannot freeze the page. Everything stays in your browser.
Runs locally in your browserHow to use Regex Tester
- Enter a pattern. Type a regular expression and tick the flags you need.
- Add test text. Paste the text to search in the test string box.
- Test. Click Test to see highlighted matches, positions and capture groups.
Example
Finding ISO dates and capturing year, month and day.
Pattern
(\d{4})-(\d{2})-(\d{2})Test string
Released 2024-03-15, patched 2024-04-02.
Options: Flag g
Matches
Match 1 at 9: 2024-03-15 (groups: 2024, 03, 15) Match 2 at 29: 2024-04-02 (groups: 2024, 04, 02)
Formats, limits and privacy
- Input
- Plain text
- Output
- Plain text
- Limits
- JavaScript regular expressions only, as supported by your browser.
- Shows up to 1000 matches.
- Each test is stopped after 2 seconds so a runaway pattern cannot freeze the page.
- Privacy
- Everything happens in your browser. Your input is never uploaded to a server.
Troubleshooting
Only the first match is found
Turn on the g flag to find every match.
A pattern copied from Python or PHP shows a syntax error
Some syntax differs between flavours. Possessive quantifiers (a++), atomic groups and inline modifiers such as (?i) are not JavaScript; use the i flag instead of (?i).
^ and $ only match the start and end of the whole text
Turn on the m flag so they also match at each line break.
Backslashes behave differently in my code
Enter the pattern here as it would appear between slashes. In a JavaScript string passed to new RegExp(), every backslash must be doubled.
Frequently asked questions
Which regex flavour does this use?
JavaScript (ECMAScript) regular expressions, using your browser's own engine. Syntax from other flavours such as PCRE, Python or .NET (for example possessive quantifiers or inline modifiers) may not work.
What do the flags do?
g finds all matches instead of the first; i ignores case; m makes ^ and $ match at line breaks; s lets . match newlines; u enables full Unicode matching; y matches only at the exact start position.
Why did my test stop with a timeout message?
Some patterns, such as nested quantifiers like (a+)+$, can take exponential time on certain input ("catastrophic backtracking"). The test is abandoned after 2 seconds so the page stays responsive; simplify the pattern to fix it.
Is my text uploaded anywhere?
No. Matching runs entirely in your browser.