Regex Tester
Test and debug regular expressions with real-time matching, group capture, and cheat sheet.
What regex syntax does this tool support?
This tool supports JavaScript regular expression syntax, which is widely used in web development. It supports flags like g (global), i (case-insensitive), m (multiline), s (dotAll), and u (unicode).
How do I capture groups in my regex?
Use parentheses () to create capture groups. Matched groups are displayed below the results. For example, (\d+)-(\d+) will capture two number groups separated by a hyphen.
What are regex flags?
Flags modify how the regex engine searches. g = global (find all matches), i = case-insensitive, m = multiline (^ and $ match line boundaries), s = dotAll (. matches newlines), u = unicode mode.
Why is my regex not matching?
Common issues include: missing escape characters for special chars like . * + ?, incorrect anchors, or wrong flag settings. Check the error message displayed below the pattern input for syntax errors.
How do I match special characters?
Escape special characters with a backslash. For example, \. matches a literal dot, \* matches a literal asterisk, and \? matches a literal question mark.
What is the difference between greedy and lazy quantifiers?
Greedy quantifiers (*, +, ?, {}) match as much as possible, while lazy quantifiers (*?, +?, ??, {}?) match as little as possible. For example, <.*> matches the entire string, while <.*?> matches the shortest possible tag.
How do I use character classes?
Character classes [abc] match any single character in the brackets. You can use ranges like [a-z] for lowercase letters, [0-9] for digits, or [^abc] to negate (match anything except a, b, or c).
Can I test multiple patterns at once?
No, this tool tests one pattern at a time. However, you can quickly switch between patterns and test strings to compare results.
Does this tool support lookaheads and lookbehinds?
Yes, JavaScript regex supports positive lookahead (?=), negative lookahead (?!), positive lookbehind (?<=), and negative lookbehind (?<!) assertions.
How do I match unicode characters?
Use the u flag to enable unicode mode. Then you can use \u{XXXX} syntax for unicode code points, or character properties like \p{Letter} to match any letter in any language.
What are anchors in regex?
Anners are zero-width assertions that match positions, not characters. ^ matches the start of a line (or string), $ matches the end, \b matches word boundaries, and \B matches non-word boundaries.
How do I replace matched text?
Switch to the Replace tab and enter your replacement pattern. You can use $1, $2, etc. to reference captured groups. The replacement is applied to all matches when using the g flag.