// live match highlighting · capture groups · flags · common patterns · javascript regex engine
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.
g global, i case-insensitive, m multiline, s dotAllA regular expression (regex or regexp) is a sequence of characters that defines a search pattern. They are used for string searching and manipulation across virtually every programming language. While the syntax can look intimidating at first, regular expressions are built from a small set of concepts that combine in powerful ways.
Literal characters match themselves — the regex cat matches the string "cat" anywhere in the text. Special characters called metacharacters have special meanings: . matches any character, * means zero or more of the preceding element, + means one or more, ? means zero or one, and ^ and $ anchor to the start and end of a line.
Character classes let you match any character from a set — [aeiou] matches any vowel, [0-9] matches any digit, and \w matches any word character (letter, digit, or underscore). Capture groups using parentheses let you extract specific parts of a match for further processing.
g (global) — Find all matches in the string instead of stopping after the first. Almost always what you want when testing patterns.
i (case insensitive) — Make the match ignore the difference between uppercase and lowercase letters. The pattern cat with the i flag matches "cat", "Cat", "CAT", and "cAt".
m (multiline) — Make ^ and $ match the start and end of each line rather than the entire string. Essential when working with multiline text.
s (dotAll) — Make the dot . match newline characters too. By default, . matches everything except newlines.
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.(\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}).. 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.* 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.\. matches a literal dot. \( matches a literal opening parenthesis. Special characters that need escaping: . * + ? ^ $ { } [ ] | ( ) \