Regex Tester
Test regular expressions against any string with live match highlighting. All processing is in-browser.
Pure browser JavaScript — uses the built-in RegExp engine.
How to use this tool
- Enter a pattern (e.g. \b\w+\b).
- Set flags (g=global, i=case-insensitive, m=multiline).
- Type a test string — matches highlight in real time.
Test regular expressions against any string with live match highlighting. All processing is in-browser.
How it works
The Regex Tester lets you write a regular expression and immediately see which parts of a test string it matches, highlighted in real time. It uses the JavaScript RegExp engine, which is the native engine for browser-based and Node.js applications.
Enter your pattern in the regex field and your test string below. Supported flags include g (find all matches), i (case-insensitive), m (multiline), and s (dot matches newline). Match positions and capture group values are displayed alongside the highlighted text.
Regular expressions are powerful for tasks like validating email addresses and phone numbers, extracting structured data from unstructured text, finding and replacing patterns in code or logs, and filtering lines in a file.
The tester runs entirely in the browser, so you can safely test patterns against real data including personally identifiable information or internal log excerpts.
Worked example
Extract all email addresses from a block of text
- Enter the pattern: [a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,}
- Enable the 'g' (global) flag to find all matches, not just the first.
- Paste your text block into the test input.
- All matched email addresses are highlighted in the output.
- Copy the list of matches from the results panel.
Every email address in the text is highlighted and listed as a separate match.
Common mistakes to avoid
- Forgetting the 'g' flag when you want all matches -- without it, only the first match is returned.
- Escaping characters unnecessarily inside a character class [] -- inside brackets, most metacharacters lose their special meaning and do not need escaping.
- Using .* (greedy) when you need .*? (lazy) -- greedy quantifiers match as much as possible, which often captures too much text between delimiters.
Key terms
- Regular expression (regex)
- A sequence of characters that defines a search pattern. Used for matching, extracting, and replacing text according to flexible rules.
- Capture group
- A portion of a regex enclosed in parentheses that captures a sub-match for extraction.
- Flag
- A modifier appended to a regex that changes matching behaviour, such as 'g' for global (find all matches) or 'i' for case-insensitive matching.
Frequently asked questions
- Which flags are supported?
- g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode), y (sticky) — the full JavaScript RegExp flag set.