Regex Tester (JavaScript)
Test JavaScript regular expressions with matches highlighted as you type. See groups and named groups, toggle flags, and try replacements.
3 matches.
| # | Match | Line:col | Groups |
|---|---|---|---|
| 1 | 2026-10-12 | 1:24index 23 |
|
| 2 | 2026-11-30 | 2:33index 67 |
|
| 3 | 2027-06-01 | 2:65index 99 |
|
Runs in your browser. Nothing you enter is uploaded.
How to use
This tool tests a JavaScript regular expression against your text, highlights every match as you type, and can replace the matches.
- Type the pattern into Pattern, without the slashes, or start from one in Common patterns, such as email addresses or dates. You can also paste a whole literal like
/\d+/giover the pattern, and the tool splits off the flags. - Turn flags on or off:
- g finds every match, not just the first.
- i ignores case. m makes
^and$match at each line. s lets.match line breaks too. - u and v turn on Unicode mode, needed for
\p{L}and to treat an emoji as one character. v also allows sets like[\w--\d]. - y matches only where the last match ended. d records group positions.
- Paste your text into Test text. Matches are highlighted in two alternating colors, and an empty match shows as a thin line. You can open a text file for it too.
- Matches lists each match with its line and column and its groups. Copy matches copies them all, one per line. Copy as literal copies the pattern as
/pattern/flagsfor your code. - Replace shows the text with every match replaced. Use
$1or$<name>for a group,$&for the whole match, and$$for a dollar sign.
Mistakes in the pattern are explained in plain words. A pattern that runs for more than a second is stopped, so a runaway pattern can't freeze the page. Up to 10,000 matches are listed.
The tool uses your browser's own JavaScript engine, so results are what your code will get. Other engines, like PCRE in PHP or Python's re, differ in places.
Frequently asked questions
Why does my regex work here but not in Python or PHP?
Each language has its own regex engine. This tool uses JavaScript, the same engine as your browser and Node.js. Most syntax is shared, but details differ, such as named group syntax, lookbehind and the available flags.
Why was my pattern stopped?
Some patterns try a huge number of ways to match before giving up. This is called catastrophic backtracking, and nested quantifiers like (a+)+ are the usual cause. Make the inner part more specific, or use a character class instead of alternatives.
What does the g flag change?
Without g, JavaScript finds only the first match, which is what match() and exec() return. With g, it finds them all, as matchAll() and replaceAll() do. The tool shows what your code would get.
Related tools
More text tools
- Word counter Count words, characters, sentences and paragraphs as you type.
- Slug generator Turn titles into clean URL slugs.
- Remove duplicate lines Remove duplicate lines from a list in your browser.