Developer ToolsDebugging ToolsFree Tool
Regex Tester
Test a regex pattern against sample text and see every match, using the real JavaScript regex engine.
How to Use Regex Tester
- 1Enter your regex pattern
- 2Add a line with ---, then your test text
- 3Click Process
- 4Review the list of matches found
About Regex Tester
How to use the tester
Enter your regular expression on the first line, then a line containing only ---, then the text to search. The tool runs the pattern against the text with JavaScript's regular-expression engine and lists every match it finds, along with the number of matches. If nothing matches it says so, and if the input is not in the pattern, separator, text layout it tells you what format to use.
Example
\d{3}-\d{4}
---
Call 555-1234 or 555-9876 today
The result reports 2 matches: 555-1234 and 555-9876.
Behaviour to be aware of
- Global matching. The pattern is always applied with the global flag, so all matches are returned, not just the first.
- No other flags. Matching is case-sensitive, and
^and$refer to the start and end of the whole text. For case-insensitive matching, write character classes such as[Aa]or(?:[Hh]ello). - Whole matches only. The output lists the full text matched, not the individual capture groups.
- JavaScript syntax. Features differ between engines. For example, lookbehind is supported in modern browsers, but possessive quantifiers and some Python or PCRE features are not.
- Invalid patterns such as an unclosed bracket produce an error rather than a match list.
A short pattern reference
| Pattern | Meaning |
|---|---|
\d, \w, \s | A digit, word character, whitespace |
. | Any character except a line break |
*, +, ? | Zero or more, one or more, optional |
{2,4} | Between 2 and 4 repeats |
[abc], [^abc] | Any of / none of these characters |
(a|b) | Either a or b |
\b | Word boundary |
Good habits when writing regex
- Start simple and add one piece at a time, testing after each change.
- Use anchors and boundaries so
\d{4}does not match inside a longer number. - Prefer specific classes (
[A-Za-z]) over.*, which can match far more than you expect. - Beware nested quantifiers such as
(a+)+, which can make an engine extremely slow on some inputs. - Do not rely on a regex alone to validate things like email addresses or HTML; use a proper parser or a library for those.
Related: the regex generator on this site, and the remove duplicate lines tool for cleaning match results.
Frequently Asked Questions
Your regex pattern, then a line with just ---, then the text to test it against.
Real — it constructs an actual JavaScript RegExp with the global flag and calls .match() against your test string, so results reflect genuine regex engine behavior.
No — this tool only lists the matched substrings. Use the Regex Debugger tool for match index and named/numbered group details.
No — matching happens entirely in your browser.