Regular Expression Tester
Try a regular expression on your own text and see every match and capture group. The text stays on your device.
Runs in your browser. Your input is not sent anywhere.
What this tool does
A regular expression describes a pattern of characters. The tool applies an expression to a text, marks what it matches, and lists each match with its position and the content of its capture groups.
The expression is run by the regular expression engine of your browser, so the tool tests the JavaScript dialect. Other languages share most of the syntax, but details differ.
How to use it
- Enter the expression without the slashes that surround it in JavaScript code.
- Enter the flags. The field starts with g, which finds all matches instead of only the first.
- Enter the text you want to test.
- Read the marked text and the list of matches. They are updated while you type.
Positions are counted from 1 in UTF-16 code units, as JavaScript counts them: a character outside the Basic Multilingual Plane, such as an emoji, takes two positions.
Up to 1000 matches are found. The marked text and the list show the first 200 matches within the first 100,000 characters of the text; “Copy result” copies all matches that were found, one per line.
How the result is derived
The page first creates the expression, which checks its syntax without running it. If the browser rejects the expression, its explanation is shown below the field.
The search itself runs in a Web Worker, a background thread that is separate from the page. If the worker has not answered after 2 seconds, the page ends it, reports that the expression was stopped, and starts a fresh worker for the next run. A slow expression can therefore not freeze the page.
With the flag g or y the tool asks for one match after the other until none is left. After an empty match it moves on by one character, because the search would otherwise find the same empty match forever.
Worked example
Expression: (?<year>\d{4})-(\d{2})
Flags: g
Text: From 2026-09 to 2027-01, not 99-1.1. Characters 6 to 12: 2026-09
Group 1 (year): 2026
Group 2: 09
2. Characters 17 to 23: 2027-01
Group 1 (year): 2027
Group 2: 01The end of the text, 99-1, does not match, because the expression asks for exactly four digits, a hyphen and exactly two digits. Without the flag g only the first match is reported.
Reference: flags and common syntax
| Flag | Name | Effect |
|---|---|---|
| d | Indices | Records where each group starts and ends. |
| g | Global | Finds all matches, not only the first. |
| i | Ignore case | Treats upper and lower case as equal. |
| m | Multiline | Lets ^ and $ match at the start and end of every line. |
| s | Dot all | Lets the dot match line breaks as well. |
| u | Unicode | Works with whole characters and enables \p{…}. |
| v | Unicode sets | Extends u with set operations in character classes. Cannot be combined with u. |
| y | Sticky | Matches only at the position where the last match ended. |
| Syntax | Matches |
|---|---|
| . | Any character except a line break |
| \d \w \s | A digit, a word character, whitespace |
| [abc] [^abc] [a-z] | One of, none of, a range of characters |
| a* a+ a? | Zero or more, one or more, zero or one a |
| a{2} a{2,4} | Exactly two, two to four a |
| a+? | As few a as possible instead of as many |
| ^ $ \b | Start, end, word boundary |
| (…) (?<name>…) (?:…) | Group, named group, group without capture |
| a|b | a or b |
| (?=…) (?!…) | Followed by, not followed by |
Common mistakes
- Forgetting to escape characters with a special meaning. A dot matches any character; a literal dot is written with a backslash in front.
- Doubling backslashes. In JavaScript source code inside a string, \d must be written with two backslashes; in this tool and between slashes it is written with one.
- Expecting a greedy quantifier to stop early. <.+> matches from the first < to the last > of a line. Use <.+?> or <[^>]+>.
- Leaving out ^ and $ when validating. Without them the expression is satisfied by a match anywhere in the text.
- Nesting repetition, as in (a+)+ or (\w+\s?)+. On text that almost matches, the engine may try an enormous number of ways to split the text, and the run time grows exponentially with the length. This is called catastrophic backtracking.
Sources
Frequently asked questions
- Is my test text sent anywhere?
- No. The expression runs in a background thread of the page in your browser. Neither the expression nor the text is transmitted.
- Which dialect of regular expressions does the tool test?
- The JavaScript dialect of the browser you are using. Expressions for other languages such as Python, Java or PCRE mostly behave the same, but some features differ or are missing, for example possessive quantifiers.
- What does “Stopped after 2 seconds” mean?
- The search took longer than the limit and was ended. The usual cause is catastrophic backtracking. Look for a repetition inside a repetition and rewrite it so that the text can be split in only one way.
- Why do I get a result in one browser and a stop in another?
- Browsers use different engines. In our tests with the expression ^(a+)+$ and forty letters a followed by an exclamation mark, the engine of Chromium was stopped by the limit, while the WebKit engine gave up by itself within a second and reported no match.
- Why is a group shown as “did not take part”?
- The group belongs to a part of the expression that was not used for this match, for example the other side of an alternative or an optional part that was skipped.
Last updated: September 28, 2026