Regex Tester
Test and debug regular expressions with live match highlighting, capture group display, and flag explanations — using JavaScript's native RegExp engine.
Last updated: March 25, 2026
Find this tool useful? Support the project to keep it free!
Buy me a coffeeWhat is Regex Tester?
Regular expressions (regex) are a compact pattern language for searching, matching, and transforming text — used in every programming language, text editor, database query system, and command-line tool. Despite their power, regex syntax is notoriously dense: a pattern like `^[\w.-]+@[\w-]+\.[a-zA-Z]{2,}$` can be hard to read and debug without seeing it applied to real test text in real time.
A regex tester provides immediate feedback: type a pattern in milliseconds and instantly see which parts of your test string match, which capture groups were extracted, the match positions (index offsets in the string), and how the pattern behaves with different flags (global, case-insensitive, multiline, dotAll). This shortens the regex development loop from a code-run-debug cycle to a live interactive session. The engine is JavaScript's native `RegExp`, which is also the engine used by Node.js, Deno, browsers, and any JavaScript runtime — making test results directly applicable to production code.
How to Use Regex Tester
Enter your regex pattern in the "Pattern" field (without surrounding forward slashes)
Select flags as needed using the flag toggles: g (global), i (ignore case), m (multiline), s (dotAll)
Type or paste your test string in the large "Test Input" area
Matches are highlighted in the test area in real time — each match outlined in colorful highlighting
The "Match Details" panel shows each match's full value, position index, and all named + numbered capture group values
Common Use Cases
- Testing an email validation regex against a list of valid and invalid email addresses before using it in production
- Debugging a URL extraction regex that's matching too many or too few URLs in a text block
- Writing a date format parser regex and testing it against various date string formats (MM/DD/YYYY, YYYY-MM-DD)
- Validating a phone number regex handles international formats (+1, 001, with/without dashes and parentheses)
- Testing a log file parser regex against sample log lines before using it in a data pipeline
- Building a search-and-replace regex for a text transformation script — previewing the replace output
- Testing a markdown parser regex for bold (**text**) and italic (*text*) markers
- Writing a regex for password complexity requirements and verifying it correctly flags weak passwords
Example Input and Output
Testing an email extraction regex against mixed text with multiple addresses:
Pattern: [\w.-]+@[\w-]+\.[a-zA-Z]{2,}
Flags: g (global)
Test input:
Contact us at support@example.com or
sales@company.co.uk. For press enquiries:
press.team@brand-name.org✅ 3 matches found:
Match 1: "support@example.com" (index 14–33)
Match 2: "sales@company.co.uk" (index 37–56)
Match 3: "press.team@brand-name.org" (index 79–104)
No capture groups (non-capturing pattern)
→ In JS: text.match(/[\w.-]+@[\w-]+\.[a-zA-Z]{2,}/g)Client-Side Processing
All regex testing runs in your browser using JavaScript's native RegExp engine. Patterns and test text are never sent to our servers.
Avoiding Regex ReDoS
ReDoS (Regular Expression Denial of Service) occurs when a regex with nested quantifiers causes exponential backtracking on adversarial input. Dangerous patterns: (a+)+ on "aaaaaaaaaab" — the engine tries all exponential combinations. To check: paste your pattern in this tester with a long repeated string that almost-matches. If the page freezes for >1 second, the pattern is vulnerable to ReDoS. Safe alternatives: atomic groups (not in JS), possessive quantifiers (not in JS), or restructuring the pattern to avoid nested repetition.
Named Capture Groups in Modern JS
ES2018 added named capture groups: (?<name>pattern). These are very readable: /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/.exec("2024-03-25").groups gives {year: "2024", month: "03", day: "25"}. In string.replace(), use $<name>: "2024-03-25".replace(..., "$<month>/$<day>/$<year>") → "03/25/2024". Supported in Chrome 64+, Firefox 78+, Safari 11.1+, Node.js 10+.
Frequently Asked Questions
What is the difference between the g flag and no g flag?
What are capture groups and how do I use them?
What special characters need to be escaped in a regex?
How does the regex engine match (backtracking)?
How do I match a newline character in a regex?
What is the difference between test(), match(), exec(), and replace()?
How This Tool Works
The pattern and flags are used to construct a JavaScript RegExp object: new RegExp(pattern, flags). For the test string, regex.exec() is called iteratively (or string.matchAll() for the g flag) to collect all match objects with their index positions and capture group values. Match positions are used to split the test string into non-matching and matching segments, which are rendered as spans with background highlights in the test input display. Capture group values are listed in the match details table below.
Technical Stack