Regex Tester — Test Regular Expressions
Test regex patterns with flags. See highlighted matches, count, and capture groups.
Why This Technology Metric Matters
Why: Regex is essential for text parsing, validation, and search. Testing before deploy prevents bugs.
How: Pattern compiles to RegExp. With g flag, exec() finds all matches. Captures in parentheses.
- ●g = all matches
- ●\d in JS strings
- ●Avoid catastrophic backtracking
Sample Scenarios — Click to Load
Inputs
Match Summary
Input
Output
⚠️For educational and informational purposes only. Verify with a qualified professional.
🔧 Tech Milestones
g flag finds all matches
— JS
\d = digit, \w = word char
— Regex
g = global (all matches); i = case-insensitive; m = multiline; s = dotall. Capture groups use parentheses. Escape special chars. In JS strings, backslashes must be doubled.
Frequently Asked Questions
What do the regex flags mean?
g = find all matches (global); i = case-insensitive; m = multiline (^ and $ match line boundaries); s = dotall (dot matches newlines).
How do capture groups work?
Parentheses create capture groups. The first group is match[1], second is match[2], etc. Use (?:...) for non-capturing groups.
Why is my regex not matching?
Check escaping: in JavaScript strings, backslashes must be doubled (e.g. \d for digit). Also verify flags and that the pattern matches your test string.
What is a word boundary?
\b matches between a word character (\w) and a non-word character. Useful for matching whole words only.
How do I match special characters?
Escape with backslash: \. for literal dot, \* for asterisk. In JS: "\." in the string.
What is catastrophic backtracking?
Nested quantifiers like (a+)+ can cause exponential time on certain inputs. Simplify or use atomic groups.