What Is a Regex Tester?
A regex tester lets you write a regular expression and run it against sample text to see what matches. It is useful for validating patterns, debugging extraction rules and understanding capture groups before using a regex in application code. This tester uses the browser's native JavaScript RegExp engine, so the behavior matches modern JavaScript runtimes.
The tool shows every match with its index, the matched value and any capture groups. It also highlights matches directly in the test text and reports invalid patterns with the engine error.
How to Test a Regular Expression
- Paste the text you want to search into the test string box.
- Enter a pattern, for example
(\w+)@(\w+). - Choose the flags you need: global, ignore case, multiline, dotall or unicode.
- Select Test regex and review the matches and groups.
The global flag returns all matches. Without it, the tester returns only the first match. Capture groups are numbered by the order of their opening parentheses.
Regex Flags Explained
- g (global): find all matches instead of stopping at the first.
- i (ignore case): match uppercase and lowercase letters equally.
- m (multiline): make
^and$match the start and end of each line. - s (dotall): let
.match newline characters. - u (unicode): enable Unicode-aware matching for code points and escapes.
Capture Groups
Parentheses create capture groups. For example, (\d{4})-(\d{2})-(\d{2})
applied to 2026-11-02 captures the year, month and day separately. The
match list shows each group so you can confirm that the pattern extracts the right
pieces. Non-capturing groups (?:...) group expressions without adding a
capture.
Common Patterns
Email-like pattern
[^\s@]+@[^\s@]+\.[^\s@]+
This is a practical pattern for finding email-shaped strings, not a complete validation of every RFC edge case. For production validation, combine a reasonable pattern with server-side checks.
Whitespace and empty lines
^\s*$
With the multiline flag, this matches empty or whitespace-only lines. Without multiline, it matches only when the entire string is empty or whitespace.
Digits and numbers
\b\d{3,5}\b
The word boundaries avoid matching digits inside longer tokens. Adjust the quantifier to the length you need.
Common Mistakes
Forgetting to escape special characters
Characters such as ., *, +, ?,
(, ), [ and ] have special
meanings. Escape them with a backslash when you want a literal character.
Greedy vs lazy matching
Quantifiers are greedy by default and consume as much as possible. Add ?
after a quantifier for lazy matching, for example .*?. This is useful
when extracting text between delimiters.
Anchors and multiline text
^ and $ match the start and end of the whole string unless
the multiline flag is enabled. If your pattern works on one line but not on a
multi-line document, check the flags.
Catastrophic backtracking
Nested quantifiers and ambiguous alternatives can make a pattern extremely slow on long input. Test with realistic text and simplify patterns where possible. Avoid running untrusted regex patterns against very large documents in production.
Lookahead and Lookbehind
Lookarounds assert that something appears before or after the current position
without consuming it. (?=...) is a positive lookahead,
(?!...) is a negative lookahead, (?<=...) is a positive
lookbehind and (?<!...) is a negative lookbehind. For example,
\d+(?= USD) matches digits followed by “ USD” but does not include the
suffix in the match. Lookbehind is supported by current JavaScript engines, but
older runtimes may not support it.
Debugging Checklist
- Start with a small sample that contains one expected match.
- Test with and without the global flag to separate “first match” from “all matches”.
- Escape literal characters such as dots, brackets and parentheses.
- Check anchors and multiline mode when testing across multiple lines.
- Keep capture groups minimal; use non-capturing groups when you do not need the value.
- Watch performance on long text and avoid ambiguous nested quantifiers.
When to Use Find and Replace
This page is for testing and inspecting matches. When you are ready to apply a pattern across a document, use the Find and Replace tool, which supports regex replacements and capture group references. To compare the result with the original, use Text Diff.
Related Tools
Clean up the test text with Text Minifier, format structured payloads with the JSON Formatter, or compare versions with Text Diff.