
Regex Tester
Test regular expressions with real-time match highlighting and capture groups. 100% client-side.
Last reviewed: June 2026New to this tool? Click here for instructions
Quick Answer
A regex tester lets you build and debug a regular expression against sample text, highlighting every match in real time. Enter a pattern and test string above to see matches, capture groups, and the effect of flags like g, i, and m. It runs entirely in your browser — nothing is sent to a server — so it is safe for testing patterns against sensitive text.
How to Use the Regex Tester
This tester is built for JavaScript regular expressions. Enter the pattern body without the surrounding slashes, choose the flags that match your production code, and paste a realistic sample string. The page highlights matches immediately, reports index positions, and lists capture groups so you can see exactly what the browser's RegExp engine is returning.
- Enter a pattern. Type only the expression itself, such as
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b. Use the flag controls instead of typing/pattern/gim. - Pick flags deliberately. Start with
gwhen you need every match, addifor case-insensitive matching, and usemwhen^and$should work per line instead of only at the start and end of the entire string. - Paste representative text. Include normal examples, empty values, punctuation, line breaks, and failure cases. Regexes that pass a single happy-path sample often fail when whitespace or repeated values appear.
- Read the match table. Confirm the matched text, zero-based index, and captured groups. If the first match is correct but later matches are missing, check the global flag and greedy quantifiers.
- Use the explanation panel. The explanation breaks the pattern into recognizable parts so you can find escaping mistakes, misplaced anchors, and groups that are broader than intended.
Recommended Debugging Workflow
Build complex patterns in layers. First match the smallest literal token, then add one character class or quantifier at a time. After each change, test against examples that should match and examples that should not. This makes it much easier to catch the exact step where a pattern became too broad, too narrow, or too slow.
For extraction work, name or isolate the group you actually need. A pattern that matches a whole log line is useful for validation, but a pattern with clear capture groups is better when the next step is transforming data, routing requests, or writing parser code.
JavaScript Regex Syntax Quick Reference
JavaScript regex syntax is compact, which is useful once a pattern works and painful while you are still debugging it. Use this reference while testing to connect the highlighted matches back to the token that caused them.
| Token | Meaning | Example |
|---|---|---|
. | Any character except line terminators unless s is enabled. | a.c matches abc |
[abc] | One character from a set. | [0-9] matches one digit |
[^abc] | One character not in the set. | [^,]+ reads until a comma |
*, +, ? | Repeat zero or more, one or more, or optional. | \s+ matches whitespace runs |
{n,m} | Repeat a specific number or range. | \d{2,4} matches 2 to 4 digits |
^, $ | Anchor to the start or end of input, or to each line with m. | ^ERROR finds log lines that begin with ERROR |
(...) | Capture a matched subexpression. | (\d{4})-(\d{2}) captures year and month |
(?:...) | Group without capturing. | (?:GET|POST) |
| | Match one alternative or another. | json|yaml |
(?=...), (?<=...) | Look ahead or behind without consuming the surrounding text. | \d+(?=ms) matches the number before ms |
Common Regex Mistakes to Check
- Forgetting to escape special characters. Match a literal period with
\., not., and remember that backslashes may need an extra escape when the pattern is moved into a JavaScript string literal. - Using greedy matches too broadly.
.*often captures more than intended. Try a negated character class such as[^<]*or a lazy quantifier such as.*?when the stop condition is clear. - Confusing global and single-match behavior. The tester can show every match with
g, but code that callsString.match,RegExp.exec, orString.matchAllmay return different shapes depending on flags. - Relying on anchors without testing line breaks. The multiline flag changes how
^and$behave. Add a multi-line sample before using anchored patterns in log processing or form validation. - Over-validating complex formats. Regex is useful for quick checks and extraction, but full validation for URLs, email delivery, JSON, HTML, or language grammar usually needs a parser or a domain-specific validator.
Frequently Asked Questions
\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b. Use the flag controls for options like global, ignore case, multiline, dotAll, and unicode.