Embed this tool on your site
About this tool
Regex Tester is a JavaScript regular expression workbench that lists every match in your test text as you type, with no page reload. Enter a pattern without slashes, type flags such as g, i, m, s, u or y into the Flags field, and paste the text to search. The tool always searches for all matches, adding the g flag if you leave it out, then shows a match count and a numbered list: each entry gives the matched text, its start index and any capture groups as $1, $2 and so on. Invalid patterns show the browser's error message instead of failing silently. Because it uses the browser's native RegExp engine, named groups, lookaheads, lookbehinds, lazy quantifiers and Unicode property escapes (with the u flag) all work. Developers use it to build validation patterns, test log-parsing expressions and understand what an existing regex matches before changing it.
Why use it
Live Match List: The match count and list update on every keystroke in the pattern, flags or test text, so you can see immediately whether a pattern is too broad or too narrow.
Capture Groups Per Match: Each match lists its capture groups in order as $1, $2 and so on, so you can check that a multi-group pattern extracts the right pieces. Named groups are listed by position.
Instant Syntax Error Feedback: Invalid regex syntax shows the JavaScript engine's error message as you type, so a broken pattern is never mistaken for one that simply has no matches.
Full JavaScript RegExp Feature Set: The tester uses the browser's native RegExp engine, so it supports the complete modern JavaScript syntax: named captures (?<name>...), lookahead and lookbehind assertions, Unicode property escapes (\p{L}), non-greedy quantifiers, and the s (dotAll) and u flags introduced in ES2018.
Multiline Test Strings: Paste an entire log file excerpt, a block of addresses, or multi-paragraph text into the test area. With the m flag enabled, ^ and $ match at the start and end of each line, and the match counter and list update to reflect all occurrences across every line.
Every Match Found: The tester always runs a global search, adding g if it is missing, so the list never stops at the first match by accident.
How to use
- Type your regular expression pattern into the pattern field — do not include leading or trailing slashes.
- Type flags into the Flags field (for example gi or gm); g is filled in by default, and all matches are listed even without it.
- Paste or type your test text into the Test text box; results update as you edit the pattern, flags or text.
- Read the match count and the list below it — each entry shows the matched text, its start index, and capture groups as $1, $2 and so on.
- If the pattern has a syntax error, an Invalid regex message with the browser's parser error appears; fix the pattern and it clears.
When it helps
- Building and iterating on an email, phone number, or URL validation pattern before adding it to a form.
- Testing a log-parsing regex against a sample log excerpt to confirm it extracts the right fields.
- Understanding what an existing regex in a codebase actually matches before modifying it.
- Crafting a search-and-replace pattern for a code editor's find-and-replace with regex mode.
- Verifying that capture groups in a complex pattern return the expected substrings for all edge-case inputs.
- Learning regex syntax interactively by writing a pattern and immediately seeing which parts of the test string it matches.
Examples
01Extract all email addresses from text
InputPattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}
Test: 'Contact alice@example.com or support@utilitykit.tools for help.'
Expected result2 matches found
[1] "alice@example.com" at index 8
[2] "support@utilitykit.tools" at index 29
02Named capture groups for ISO date parsing
InputPattern: (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})
Test: 'Release date: 2025-11-03, patch date: 2026-01-15'
Expected result2 matches found
[1] "2025-11-03" at index 14
Groups: $1="2025", $2="11", $3="03"
[2] "2026-01-15" at index 38
Groups: $1="2026", $2="01", $3="15"
03Case-insensitive word match with i flag
InputPattern: error (flags: gi)
Test: 'Error logged. ERROR count: 2. Possible errors downstream.'
Expected result3 matches found
[1] "Error" at index 0
[2] "ERROR" at index 14
[3] "error" at index 39
Tips
- The tester always finds every match; if your own code calls match or exec without the g flag, it will only return the first one.
- Named groups such as (?<year>\d{4}) make a pattern easier to read; the match list shows them by position ($1, $2), so count groups from the left.
- To match a literal backslash, type two backslashes (\\) in the pattern field; you need four only when writing the pattern inside a JavaScript string literal.
- The \b word-boundary assertion is zero-width, so it does not consume characters. Use it to match whole words (\bword\b) rather than substrings — otherwise 'password' would match a pattern intended only for 'word'.
- Start with the simplest pattern that could possibly work, then add constraints — it is much easier to narrow a too-broad pattern than to debug a too-complex one that matches nothing.
Frequently Asked Questions
Which regex engine does this tool use?⌄
The tool uses the browser's native JavaScript RegExp engine, which implements the ECMAScript regular expression specification. This means results are accurate for JavaScript code but may differ slightly from PCRE (used in PHP, Python re, Perl) or POSIX regex dialects.
Why does my pattern match nothing even though I think it should?⌄
Common causes include case differences (add the i flag), PCRE syntax not supported in JavaScript (such as \K or possessive quantifiers), ^ and $ anchors on multi-line text without the m flag, or invisible whitespace in the test text.
How do I test a pattern with special regex characters in the input?⌄
Special characters in the test string (the input you are matching against) need no escaping — only the pattern field uses regex syntax. If you want to match a literal dot, question mark, or parenthesis in the pattern, escape it with a backslash: \., \?, \(.
What is the difference between the m and s flags?⌄
The m (multiline) flag makes ^ and $ match at the start and end of each line rather than just the whole string. The s (dotAll) flag makes the . metacharacter match newline characters as well as all other characters — it has no effect on ^ and $ anchors.
Can I test patterns with lookaheads and lookbehinds?⌄
Yes. The JavaScript engine in modern browsers supports both positive and negative lookaheads ((?=...) and (?!...)) and lookbehinds ((?<=...) and (?<!...)). Lookbehinds require a current-generation browser (Chrome 62+, Firefox 78+, Safari 16.4+).
Why does the g flag matter?⌄
In JavaScript, a regex without g stops after the first match in methods like exec and match. This tester always lists every match because it adds g automatically, so check your own code for the flag: results here can show more matches than a call without g.
Can I use this to test patterns for Python or PHP?⌄
The tool uses the JavaScript engine, so syntax is slightly different from Python's re module or PHP's PCRE. Most common patterns work identically, but Python-specific syntax like (?P<name>...) named groups or PHP-specific modifiers will not work. Use it as a close approximation and verify in the target language.
Is there a risk of catastrophic backtracking with complex patterns?⌄
Yes. Poorly written patterns with nested quantifiers can cause exponential backtracking, making the browser tab appear to freeze. The tool does not impose a timeout by default, so be cautious with patterns like (a+)+ against long strings. If the page becomes unresponsive, refresh to reset.
Glossary
- Regular Expression
- A sequence of characters that defines a search pattern, used for matching, extracting, and replacing text. Supported by virtually every programming language and most text editors.
- Capture Group
- A portion of a regex pattern enclosed in parentheses that isolates a matched substring for extraction. Named groups use the syntax (?<name>...) for clearer code.
- Flag
- A modifier appended to a regex literal that changes matching behaviour — for example, i for case-insensitive, g for global (find all matches), m for multiline anchors, and s for dotAll mode.
- Lookahead
- A zero-width assertion (?=...) or (?!...) that checks whether a pattern follows the current position without consuming characters. Does not appear in the match.
- Quantifier
- A symbol that specifies how many times the preceding element must match: * (zero or more), + (one or more), ? (zero or one), {n,m} (between n and m times).
- Catastrophic Backtracking
- A performance failure caused by patterns with ambiguous overlapping quantifiers, where the regex engine explores an exponential number of match paths, causing near-infinite execution time.
A LITTLE HELP. A LOT DONE.
Good tools.
Great flow.
Your shortcut to the everyday. Create, convert, calculate,
and get back to what you love.
✳
✳
✓ Free to use✓ No sign-up✓ 500+ possibilities