Regex Tester
Test JavaScript regular expressions live. See matches, capture groups, and run replace previews.
Matches and capture groups appear here
Replacement result appears here
What is a Regex Tester?
A regex tester lets you write, test, and debug regular expressions interactively. As you type, it highlights all matches in the test string, shows captured groups, and reports syntax errors in the pattern — so you can iterate quickly without writing code.
This tool supports JavaScript regex syntax (ECMAScript), with flags for case-insensitive (i), global (g), multiline (m), and dotAll (s) matching.
How to test a regex online
- Enter your regex pattern in the Pattern field (without surrounding slashes).
- Set any flags you need (g, i, m, s).
- Paste or type your test string in the Test String area.
- All matches are highlighted in real time, and captured groups are listed below.
Frequently Asked Questions
What is a regular expression?
A regular expression (regex) is a sequence of characters that defines a search pattern. It is used to find, match, extract, or replace text in strings. Regexes are supported in virtually every programming language.
What does the g flag do?
The g (global) flag makes the engine find all matches in the string, not just the first one. Without g, the regex stops after the first match.
What is a capture group in regex?
A capture group is a part of the pattern enclosed in parentheses. When the pattern matches, the content matched by each group is captured separately and can be referenced in replacement strings or extracted programmatically.
What is the difference between greedy and lazy matching?
Greedy quantifiers (.*) match as many characters as possible. Lazy quantifiers (.*?) match as few characters as possible. For example, matching a tag pattern against a string with multiple tags gives the entire string with greedy matching, but only the first tag with lazy matching.
What regex flavour does this tool use?
This tool uses JavaScript (ECMAScript) regex, which is supported natively in the browser. It is broadly compatible with most modern regex engines but has some differences from PCRE used in PHP, Python, and Perl.