Regex Tester (JavaScript)
Test a JavaScript (ECMAScript) regular expression against your text: matches are highlighted as you type, and each match lists its position and capture groups.
hello@example.comat index 14support@flexypdf.comat index 35About the Regex Tester
Type a pattern, choose flags and paste some sample text: every match is highlighted straight away, and the Match Details list shows where each match starts and what each capture group caught. It is a quick way to check a pattern before it goes into a form validation rule, a search-and-replace or a log parser.
Patterns are run by your browser’s own RegExp engine, so the results follow JavaScript (ECMAScript) rules exactly as they would in your code. That matters because regex flavours differ: lookbehind, named groups such as (?<year>\d{4}) and the s (dotAll) flag work here, while features found only in PCRE or Python, such as possessive quantifiers, atomic groups or inline modifiers like (?i), report a syntax error. The error message comes straight from the browser.
Flags can be toggled with the buttons (g, i, m, s, u and y) or typed into the box after the closing slash. Without g, only the first match is shown, just like RegExp.prototype.exec() in code. For example, the default pattern (\w+)@(\w+\.\w+) with the flags gi finds both email addresses in the sample sentence and lists the user name and domain as groups 1 and 2.
The copy icon next to the flags copies the pattern as a ready-to-paste literal such as /a\/b/g, escaping forward slashes for you. To format the surrounding code, use the Code Beautifier.
How to use the Regex Tester
- 1
Enter the pattern
Type the regular expression between the slashes, without adding slashes of your own.
- 2
Set the flags
Click the flag buttons or type letters in the flags box: g for all matches, i to ignore case, m for line-by-line ^ and $, s so a dot also matches newlines, u for Unicode mode, y for sticky matching.
- 3
Add test text
Paste the text you want to search into Test String.
- 4
Read the results
Matches are highlighted under Result, and Match Details lists each match’s index and groups.
- 5
Copy the regex
Click the copy icon to copy it as a JavaScript literal in the form /pattern/flags.
What it can do
Native JavaScript engine
Uses the browser’s RegExp, so behaviour matches your JavaScript or TypeScript code.
Live highlighting
Every match is marked in the text as you type, with a running match count.
Capture groups
Numbered and named groups are listed for each match; a group that did not take part shows as (no match).
All standard flags
Buttons for g, i, m, s, u and y; other flags your browser supports, such as d or v, can be typed.
Correct empty matches
Patterns that can match an empty string, like a* or \b, are stepped through properly instead of stopping after the first one.
Copy as literal
Forward slashes in the pattern are escaped automatically.
Limitations
- JavaScript flavour only. PCRE (PHP), Python, Java and .NET support different features, so a pattern that works here may need changes elsewhere, and the other way round.
- There is no replace mode and no plain-English explanation of the pattern.
- Match Details stops at 1,000 matches to keep the page responsive.
- Patterns prone to catastrophic backtracking, such as
(a+)+$on long text, can freeze the browser tab, because matching runs on the page’s main thread. Reload the page if that happens.
Privacy
Your pattern and test text are processed by your browser’s JavaScript engine and are not sent to FlexyPdf.
Frequently asked questions
Why does my pattern find only one match?
The g (global) flag is off. Without it, a JavaScript regex stops after the first match. Click the g button or add g to the flags box.
How do I match across several lines?
Two different flags help. m makes ^ and $ match at the start and end of every line instead of the whole text, and s lets . match newline characters, so start.*end can span lines.
Do I need to escape forward slashes?
Not in the pattern box: type / as it is. Slashes only need a backslash inside a regex literal in code, and the copy icon adds those for you.
Will this pattern work in Python or PHP?
Often, but not always. Character classes, quantifiers and groups are shared, while lookbehind rules, named-group syntax, Unicode handling and some escapes differ. Test it in the target language before relying on it.
Why did the page freeze after I typed a pattern?
Some patterns, usually nested quantifiers like (x+)+ followed by something that fails, take exponential time on certain inputs. This is called catastrophic backtracking. Reload the page, then make the pattern more specific, for example by replacing .* with a negated class like [^,]*.
Ratings & Reviews
Rate Regex Tester
Help others by sharing your experience. Your rating is shown without your name.
More Developer Tools
View all →Code Beautifier
Re-indent JavaScript, SQL, JSON, HTML, CSS and XML code
JSON Formatter & Validator
Validate, pretty-print or minify JSON
XML Validator
Check that XML is well-formed and see where it breaks
Markdown Editor
Write Markdown with a live GitHub-style preview