Regex Tester

Test regular expressions live with match highlighting and capture groups.

  • Runs in your browser
  • Free, no sign-up
Matches

Match details

No matches yet.

How the pattern reads

  1. Type a pattern to see it explained.

Replace

Type a pattern to start

About the Regex Tester

Regular expressions are powerful and easy to get wrong. The Regex Tester shows you what a pattern really does while you type it: every match is highlighted in your test text, each match is listed with its position and capture groups, and the pattern is explained piece by piece in plain English.

It uses the JavaScript regex engine built into your browser, the same one that runs in Chrome, Node.js and other JavaScript environments, so what works here works in your code. All the flags are available: global, ignore case, multiline, dotAll, Unicode and sticky. A Replace box shows the result of a find-and-replace, with $1, $<name> and $& references.

Common patterns for email addresses, URLs, IP addresses, dates, hex colors, US phone numbers, HTML tags and repeated words are one click away. A pattern that takes too long is stopped after 2 seconds instead of freezing the page. Everything runs in your browser, so your text stays on your device.

How to use it

  1. Type a patternEnter the regular expression without the surrounding slashes, or pick one from Common patterns. The flags you have chosen appear after the closing slash.
  2. Add test textPaste the text you want to search, or click Sample to load a few lines with emails, links, dates, colors and phone numbers.
  3. Read the resultsMatches are highlighted on the right, the status line counts them, and Match details lists each match with its index and groups.
  4. Check the explanation"How the pattern reads" breaks the pattern into tokens and explains each one, indented by group.
  5. Try a replacementType a replacement in the Replace box to see the changed text. Use Copy as /regex/ to copy the pattern with its flags for your code.

Key features

Live highlighting

Every match is marked as you type, in alternating colors so neighboring matches are easy to tell apart. Empty matches show as a thin marker.

Groups and named groups

Match details lists each capture group by number and each named group by name, and shows "none" when a group did not take part.

Plain-English explanation

Each token is explained, from \d and \b to lookbehinds, lazy quantifiers and back-references.

Replace preview

See find-and-replace results with $1, $<name>, $& and the other replacement patterns JavaScript supports.

Safe from runaway patterns

Matching runs in the background and stops after 2 seconds, so a pattern with catastrophic backtracking cannot freeze the page.

Private by design

Your pattern and text are processed in your browser. Nothing is uploaded.

Examples

The built-in patterns on the sample text

Click Sample, then pick each pattern from the list:

PatternMatches
Email addressana.silva@example.com, support+billing@shop.example.org
URLhttps://example.com/guide?page=2, http://test.org
IPv4 address192.168.1.20
Date (YYYY-MM-DD)2026-03-14 (but not 2026-13-40)
Hex color#2b59ff, #fff, #C6F24E
US phone number+1 415 555 0132, (555) 123-4567
HTML tag4 tags: <p class="note">, <strong>, </strong>, </p>
Repeated wordis is

The date pattern checks that the month is 01 to 12 and the day 01 to 31, so 2026-13-40 is skipped.

Named groups and replacing

The date pattern has three named groups:

\b(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])\b

On the sample, Match details shows one match at index 157 with year 2026, month 03 and day 14. Enter $<month>/$<day>/$<year> as the replacement and the text reads "replied at 03/14/2026".

Numbered groups

With the pattern (\d{3})-(\d{4}) and the text "Call 555-0132 or 555-0199.", you get 2 matches and 2 groups each. The replacement $1.$2 turns the text into "Call 555.0132 or 555.0199."

What the flags change

Pattern and textWithout flagWith flag
colou?r on "Color and colour, COLOR."1 matchi: 3 matches
^\w+ on three lines: Alpha, Beta, Gamma1 matchm: 3 matches

Without g, only the first match is found.

A pattern that never finishes

Try (a+)+$ on 32 letter a's followed by a b. The engine would try billions of ways to split the a's, so after 2 seconds the tester stops it and says the pattern "probably backtracks too much". Rewritten as a+$, which matches exactly the same strings, it finishes instantly.

Copying for your code

Copy as /regex/ escapes forward slashes for you. The pattern https?://\S+ with the g flag is copied as /https?:\/\/\S+/g, ready to paste into JavaScript.

Tips

  • Build patterns in small steps. Start with the part you are sure about, check the highlights, then add the next piece.
  • Use named groups like (?<year>\d{4}) instead of numbered ones. They make both the pattern and the replacement much easier to read.
  • Paste examples of text that should not match as well as text that should. A pattern that matches too much is the most common regex bug.
  • Read the explanation when a pattern behaves oddly. It often reveals an unescaped dot, a misplaced quantifier or a missing group.
  • Turn on the u flag when your text contains emoji or other characters outside the basic range, and when you use \p{...} Unicode classes.

Common mistakes and limits

  • Forgetting to escape special charactersA dot matches any character, so example.com also matches "exampleXcom". Write example\.com to match a real dot. The same goes for ? + * ( ) [ ] { } ^ $ | and \.
  • Expecting all matches without the g flagWithout g, JavaScript stops at the first match, and replacing changes only the first occurrence.
  • Assuming ^ and $ mean line startsWithout the m flag, ^ and $ match only at the very start and end of the whole text. Turn on m to match at every line.
  • Using patterns from other languages unchangedThis tester uses JavaScript regex. Features like possessive quantifiers or atomic groups from PCRE, and some Python syntax, are not supported and show a pattern error.
  • Nesting quantifiersPatterns like (a+)+ or (\w*)* can take exponential time on text that almost matches. Simplify them, or make the inner part unambiguous.

Frequently asked questions

Which regex flavor does this tester use?
JavaScript (ECMAScript), using your browser's own engine. Results match what you get with RegExp in browsers and Node.js.
What do the flags g, i, m, s, u and y do?
g finds all matches, i ignores upper and lower case, m makes ^ and $ match at line breaks, s lets the dot match line breaks, u turns on full Unicode mode, and y (sticky) only matches at the current position.
How do I use capture groups in the replacement?
Write $1, $2 and so on for numbered groups, $<name> for named groups and $& for the whole match. $$ inserts a dollar sign.
Why does my pattern show an error?
The pattern is not valid JavaScript regex, for example an unclosed [ or ( or a quantifier with nothing before it. The status line shows the browser's error message.
Why was my pattern stopped?
It took more than 2 seconds, which almost always means catastrophic backtracking. Look for nested quantifiers like (a+)+ and simplify them.
Is there a limit on matches?
The first 5,000 matches are found and highlighted, and the first 500 are listed in Match details. Replace always changes the whole text.
Can I test lookbehind and Unicode property escapes?
Yes. Lookbehind (?<=...), named groups and \p{L}-style classes with the u flag all work in current browsers.
Is my text uploaded?
No. Patterns are matched in your browser, and your test text is never sent to a server.