Regex Tester
Test and debug regular expressions in real time — see matches highlighted, groups extracted, and replacements applied instantly.
Enter a regex pattern and test string. Matches are highlighted in real time. Use the Replace tab to test substitutions with capture group references like $1.
What is Regex Tester?
Regex Tester evaluates your regular expression against a test string in real time, highlighting every match and displaying capture group values for each one. Switch to Replace mode to preview substitution results with full group reference support ($1, $2, etc.).
Flags are toggleable individually: g (global), i (case-insensitive), m (multiline), and s (dot matches newlines). Pattern errors are shown inline so you can fix them without leaving the tool. All matching runs in your browser — no server round-trips, instant feedback as you type.
Common Use Cases
- Debugging a regex that should match URLs, emails, or phone numbers
- Extracting capture groups from log lines or structured text
- Testing a replacement pattern before using String.replace() in code
- Validating input patterns before adding them to form validation logic
- Learning regex syntax by experimenting with live feedback
How to Use Regex Tester
- Enter your regular expression pattern in the pattern field and toggle flags as needed.
- Type or paste your test string in the Test String area — matches are highlighted immediately.
- Switch to Replace mode and enter a replacement string to preview substitution results.
Related Tools
FAQ
Which regex flavour does this tester use?
The tester uses JavaScript's built-in RegExp engine, which follows the ECMAScript specification. This matches the behaviour of regex in Node.js, browsers, and most modern JavaScript runtimes. It supports standard character classes, quantifiers, groups, lookaheads, and lookbehinds, but does not support some features found in PCRE (like possessive quantifiers or atomic groups).
What does the 'g' flag do?
The global flag (g) makes the regex find all non-overlapping matches in the string, not just the first one. Without g, the regex stops after the first match. The tester always enables g for the purpose of highlighting all matches; the flag toggles whether it is included when the expression is used in Replace mode.
How do I use capture groups in a replacement?
In JavaScript regex replacements, use $1, $2, etc. to reference the first, second, etc. capture group in the pattern. Named groups are referenced with $<name>. For example, a pattern (\d{4})-(\d{2})-(\d{2}) with replacement $3/$2/$1 converts a date from YYYY-MM-DD to DD/MM/YYYY.
What is the difference between a capturing group and a non-capturing group?
A capturing group (parentheses without ?) captures the matched text and makes it available as $1, $2, etc. A non-capturing group (?:...) groups expressions for quantifiers or alternation without capturing — useful when you need grouping for structure but do not need the matched text in the result.
Why does my regex match too much (greedy vs lazy)?
Quantifiers like *, +, and {n,m} are greedy by default — they match as many characters as possible. Adding ? makes them lazy: *?, +?, {n,m}? match as few characters as possible. For example, <.+> matches an entire line containing multiple tags; <.+?> matches each tag individually.