Regex tester (JavaScript)
Type a pattern, as /…/flags or bare, and the text to search. It runs in this browser's JavaScript engine. The gray text is an example.
Example: dates, with the year as a named group.
Matches
| # | Match | At | Groups |
|---|
Good to know
- Which engine
- Your browser's JavaScript engine, the same that runs
text.match(/…/)in a web page or Node.js. Patterns written for PCRE (PHP), Python or .NET can behave differently: JavaScript has no possessive quantifiers, no\Aor\Z, and a$with themflag also matches before a\r. - Flags
- Write them after the pattern:
/cat/gi. A pattern typed without slashes is searched for every match (g). Withoutgonly the first match is shown, asexecfinds it. - Positions
- Counted as JavaScript counts string positions, in UTF-16 units: a character such as 😀 counts as 2. Without the
uflag a match can start inside such a character; withu(orv) it cannot. An empty match shows as a thin mark. - Slow patterns
- A pattern that backtracks without end, such as
(a+)+$on a long run of a's followed by another letter, is stopped after 0.3 seconds instead of freezing the page. - Open from a link
?pattern=/\d+/g&input=a1b22opens the page with that pattern and text. A+stays a+; write a space as%20,&as%26and#as%23.