Regex Tester
Test regular expressions with live match highlighting and capture group details.
Common Patterns
How to Use the Regex Tester
- Enter your regular expression in the pattern field between the slashes.
- Check or uncheck flags (g, i, m, s, u) to control matching behavior.
- Type your test string — matches are highlighted in real time.
- Click any Common Pattern to load a pre-built regex for emails, URLs, and more.
What is a Regex Tester?
A regex tester is an interactive tool for writing and validating regular expressions (regex) against sample text. As you type your pattern, the tool highlights all matches in real time, shows capture group values, and reports the total match count. This eliminates the slow edit-run-debug cycle and helps you understand exactly what your pattern matches before using it in code.
This tool uses JavaScript's built-in RegExp engine — the same engine used in Node.js and all major browsers.
Common Use Cases
- Form validation: Write and test patterns for email addresses, phone numbers, postal codes, and URLs
- Log parsing: Extract timestamps, error codes, or IP addresses from server log lines
- Data extraction: Pull specific fields from unstructured text or API responses
- Find-and-replace in editors: Test your regex before running a global search-and-replace in VS Code or other editors
- Input sanitization: Define allowed character patterns to validate and clean user input
FAQ
What are regex flags?
Flags modify how the regex engine matches patterns. The most common are: g (global — find all matches instead of stopping at the first), i (case-insensitive — treat uppercase and lowercase as equal), m (multiline — ^ and $ match line starts/ends rather than string start/end), s (dotAll — make . match newline characters too), and u (unicode — enable full Unicode matching).
What is the difference between + and * in regex?
+ matches one or more of the preceding element (requires at least one match). * matches zero or more (the element is optional). For example, \d+ matches "1", "42", "999" but not "" (empty string), while \d* also matches the empty string. Use + when the element must be present at least once.
What are capture groups?
Capture groups are parts of a regex enclosed in parentheses (). They capture the matched text so you can reference it later — in replacements as $1, $2, etc., or in code as match[1], match[2]. Non-capturing groups use (?:...) and group without capturing. Named groups use (?<name>...) for clearer code.
How do I match a literal dot?
In regex, an unescaped dot (.) is a special character that matches any character except newline. To match a literal dot (period), escape it with a backslash: \. For example, to match "3.14", use 3\.14 rather than 3.14 (which would also match "3X14").
What is a lookahead?
A lookahead (?=...) matches a position only if it is followed by a specific pattern, without including that pattern in the match. A negative lookahead (?!...) matches only if NOT followed by the pattern. For example, \d+(?= dollars) matches numbers followed by " dollars" without including " dollars" in the match result.