Regex tester

Test regular expressions locally and inspect matches, groups and positions.

The interactive form is ready when JavaScript is enabled.

How to use

Type a JavaScript regular expression without the surrounding slashes, add flags and paste the text to search. The result lists each match with its number, the position where it starts and the text of every capture group; a group that did not take part in the match is shown as —. You type the pattern as you would between slashes in code: one backslash, as in \d, not two.

Flags change how the pattern is applied: g finds every match instead of only the first, i ignores case, m makes ^ and $ match at the start and end of each line, s lets the dot match line breaks, u enables full Unicode matching, v is an upgraded form of u that adds set operations in character classes (use u or v, not both), y (sticky) matches only at the start of the text or right where the previous match ended, and d records the start and end of each group (the tool does not display them). Without g (or y), only the first match is shown.

Positions count from 0 and are measured in UTF-16 code units, the way JavaScript counts string length, so an emoji usually counts as two. Named groups such as (?<year>\d{4}) are listed by number, in the order their opening brackets appear.

The search runs in a separate worker and stops after half a second. A pattern with nested repetitions such as ^(a+)+$ can take exponentially longer on text that almost matches, which is known as catastrophic backtracking; instead of freezing the page, the tool stops and reports that the expression took too long to evaluate. Only the first 200 matches are listed and counted, the pattern can be 500 characters long and the text up to 100,000 characters.

The engine is the one in your browser. Patterns usually carry over to other languages, but not always: Python writes named groups as (?P<name>…), PCRE and Java have possessive quantifiers and atomic groups that JavaScript lacks, and a (?i) flag at the start of a pattern is not valid in JavaScript (recent browsers accept only the scoped form (?i:…)). Test in the target language before relying on a pattern there.

Example

Finds two email-like matches. The result shows the matched text, its starting position and captured groups.

  • \b[a-z]+@([a-z0-9-]+\.)+[a-z]{2,}\b · flags: giOn the sample text: [email protected] at position 9 and [email protected] at 35. Group 1 holds the last repetition of its group, example. and ntools., not the whole domain.
  • ^(?<key>[^=]+)=(?<value>.*)$ · flags: gmOn the lines name=Ana and city=Porto: two matches, with groups name and Ana, then city and Porto. Without m there is no match, because ^ and $ then refer to the whole text.
  • (\d{4})-(\d{2})-(\d{2}) · flag: gOn 2026-10-02 and 2027-03-01: two matches, each split into year, month and day.
  • colou?r · flags: giMatches both Color and colour: the ? makes the u optional, and i ignores the capital C.

Frequently asked questions

Are the expressions compatible with every language?

No. They use the JavaScript RegExp engine; features and escaping may differ in Python, PHP, Java or other engines.

Why does my pattern find only one match?

Add the g flag. Without it, a regular expression stops at the first match.

Why do ^ and $ not match on each line?

By default they mean the start and end of the whole text. The m flag makes them work line by line.

What does "The expression took too long to evaluate" mean?

The search took longer than half a second, usually because of nested repetitions such as (a+)+ or (.*)*. Make the repeated parts more specific, for example [^,]* instead of .*, so the engine has fewer ways to try a match.

Related tools