Regex Tester

Test regular expressions with real-time match highlighting and capture groups. 100% client-side.

Last reviewed: June 2026

New to this tool? Click here for instructions

/ / g
Test String
Highlighted Matches
Match Details
Enter a regex pattern and test string to find matches.

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.

  1. 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.
  2. Pick flags deliberately. Start with g when you need every match, add i for case-insensitive matching, and use m when ^ and $ should work per line instead of only at the start and end of the entire string.
  3. 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.
  4. 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.
  5. 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.

TokenMeaningExample
.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 calls String.match, RegExp.exec, or String.matchAll may 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

Yes. The tool compiles patterns with the browser's JavaScript RegExp engine, so the results match the syntax and behavior you should expect in modern JavaScript code.
No. Enter only the pattern body, such as \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.
Yes. The match table reports each match, its index, and captured values. JavaScript named capture groups are supported when the browser running the tool supports them.
The global flag tells JavaScript to continue searching after the first match. Without it, many regex operations return only the first match, which can hide repeated values in your sample text.
No. Pattern matching runs in your browser. Avoid pasting secrets into any web tool, but this page does not need to send your regex or sample text to a backend to produce matches.

Sources & References