Regex builder and tester
Build a regular expression from plain-English blocks, or type one yourself, and see every match highlighted in your test text with its capture groups.
Runs in your browser. Nothing you enter is uploaded.
Build a pattern
How to use the regex builder & tester
- Type a pattern and flags at the top, or pick one of the common patterns such as email or ISO date.
- Paste the text you want to search into Test text; matches are highlighted as you type.
- Check the list under the highlight for each match's position and capture groups.
- To build a pattern, choose a part and how many times it repeats, click Add part, then Use pattern.
How does the regex builder work?
Each block stands for one piece of a pattern: a digit, a letter, a word character, whitespace, any character, some exact text, or one of a set of characters. You choose how often it repeats, and the builder writes the syntax. Start of line, Digit ×3, the text "-", Digit ×4 and End of line becomes ^\d{3}-\d{4}$, which matches 555-0123.
Exact text is escaped for you, so a.b becomes a\.b and only matches a literal dot. When you repeat a piece of text that is longer than one character, it is wrapped in a non-capturing group: optional ab becomes (?:ab)?, so the whole word is optional and not just its last letter.
Which regex flags should I use?
Flags change how the whole pattern behaves. g finds every match instead of only the first. i ignores upper and lower case. m makes ^ and $ match at the start and end of every line instead of the whole text. s lets . match line breaks too, and u turns on full Unicode support. Most searches use g, often with i.
Why does my regex match too much?
Quantifiers like + and * are greedy: they grab as much as they can and only give back what the rest of the pattern needs. On the text <b>bold</b>, the pattern <.+> matches the whole string in one go. Adding a question mark makes the quantifier lazy, so <.+?> stops at the first closing bracket and matches <b> and </b> separately.
Frequently asked questions
Which regex flavour does this tester use?
It uses the JavaScript regular expression engine built into your browser, the same one Node.js uses. Most everyday syntax works the same way in PCRE, Python and Java, but some features differ: JavaScript has no possessive quantifiers or atomic groups, for example. Test in the language you will actually run the pattern in.
How do I see capture groups?
Every match is listed under the highlighted text with its position and its groups. Numbered groups appear as $1, $2 and so on, and named groups such as (?<year>\d{4}) appear with their name. The ISO date example shows three numbered groups for year, month and day.
Why does ^ only match at the start of my text?
Without the m flag, ^ and $ refer to the start and end of the whole text. Add m to make them work per line. When you click Use pattern on a built pattern that contains ^ or $, the tool adds the m flag for you.
How many matches can the tester show?
It counts up to 1,000 matches and highlights all of them in the text. The detailed list below shows the first 50, with each match's position and capture groups, which keeps the page fast on large inputs.
Is my test text uploaded anywhere?
No. Patterns and text are processed entirely in your browser by its own regex engine, so nothing you type is sent to a server. You can safely test patterns against logs or data that contain private information.