Regex Tester

// live match highlighting · capture groups · flags · common patterns · javascript regex engine

regular expression
/ /
enter a regex and test string
quick patterns
test string

What is a Regex Tester?

A regex tester lets you write and debug regular expressions against sample text in real time. It shows you exactly which parts of your string match, highlights capture groups, and tells you match positions — saving hours of trial-and-error in your code editor.

This tool uses JavaScript's native RegExp engine, so results are accurate for JS applications, Node.js backends, and browser-side validation.

How to use this tool

  • Type your regex in the top input (without slashes)
  • Toggle flags: g global, i case-insensitive, m multiline, s dotAll
  • Paste your test string — matches highlight instantly
  • Each match shows its value, index position, and capture groups
  • Use quick patterns below the regex input as starting points

Frequently Asked Questions

What does the g flag do?+
The g (global) flag makes the regex find all matches in the string, not just the first one. Without it, the regex stops after the first match. Almost always enable this when testing — without g you'll only see match #1.
What are capture groups?+
Parentheses in a regex create capture groups — they let you extract specific parts of a match. For example, (\d{4})-(\d{2})-(\d{2}) matches a date and captures year, month, and day as separate groups. Named groups use the syntax (?<year>\d{4}).
What's the difference between . and \s?+
. matches any character except a newline (unless the s flag is set). \s matches any whitespace character: space, tab, newline, carriage return, form feed. Use \s+ to match one or more whitespace characters.
Why does my regex match too much?+
Quantifiers like * and + are greedy by default — they match as much as possible. Add ? after them to make them lazy (match as little as possible): .*? instead of .*. Also use anchors ^ and $ to restrict matches to the start/end of the string or line.
How do I match a literal dot or special character?+
Escape it with a backslash. \. matches a literal dot. \( matches a literal opening parenthesis. Special characters that need escaping: . * + ? ^ $ { } [ ] | ( ) \