Skip to content

Regex tester. Live, with capture groups.

Type a JavaScript regex and a test string. Matches highlight live. Capture groups appear in the side panel with positions and content. Optional replace preview shows the transformed result. Library of common patterns, pick and edit.

/ / gi
Flags
Common patterns:
·

$1, $2 reference capture groups · $& full match · leave blank to skip preview.

Highlighted result
// matches appear highlighted here
verdict
-
matches + groups
-

Privacy: regex evaluation happens in your browser. Nothing is sent or logged.

§ · written guide

How to use the Regex Tester

This tester runs a regular expression against your text and highlights every match as you type. It uses your browser's own JavaScript RegExp engine, so the results match what the same pattern does in JavaScript or Node. Use it to build a pattern, debug one that misbehaves, or preview a find and replace before you run it on real data.

Step by step

  1. Type the pattern

    Enter the expression in Pattern without the surrounding slashes, which are drawn for you. It opens with a simple email pattern and a sample sentence, so you can see matches straight away. Results update a moment after you stop typing.

  2. Set the flags

    Toggle the Flags buttons g, i, m, s, u and y. g and i are on to start. g finds every match instead of only the first, i ignores case, m makes ^ and $ work per line, s lets the dot match line breaks, u turns on full Unicode mode and y matches only from the current position. The active flags show after the closing slash.

  3. Or start from a common pattern

    Next to Common patterns:, press email, URL, phone (US/intl), ISO date, IPv4, UUID v4, hex color or URL slug. Each one replaces the pattern, the flags and the test string with a worked example.

  4. Add your test text

    Paste your own text into Test string. Use load sample to bring back the email example sentence, or clear to empty the box.

  5. Read the matches

    The Highlighted result box marks each match, alternating green and amber so neighbors are easy to tell apart. The verdict panel gives the match count, and matches + groups lists each match with its position, length and capture groups.

  6. Preview a replacement

    Type into Replacement string (optional) to see the text after a replace. Use $1 and $2 for capture groups and $& for the whole match. The Replace preview box appears below, and copy result copies it.

Reading the results

  • With the starting email pattern and sample, the verdict reads 2 matches, with Match 1 @ pos 14 · len 25 and Match 2 @ pos 43. Positions count characters from 0 at the start of the test string.
  • Numbered groups are listed as $1, $2 and so on, and named groups by their name. A group that did not take part in a match shows (undefined), such as the time groups when the ISO date preset matches a date with no time.
  • Invalid regex means the pattern cannot be compiled, and the message underneath gives the browser's reason. No matches means it compiled but found nothing.
  • The list shows the first 200 matches and notes how many more there are. The highlight still marks all of them.

Tips and common mistakes

  • Without the g flag only the first match is found and listed. Turn g on to see every match.
  • The URL slug preset starts with no flags, so ^ and $ test the whole box as one slug and the multi line sample shows no matches. Turn on m and g to check each line separately.
  • The replace preview replaces every match when no flags are set. If you have flags but not g, it replaces only the first match, just as JavaScript would.
  • With g on, the search checks the clock between matches and stops with a timeout message after 1 second, so very long text with many matches can hit it. A single match that backtracks badly, for example with nested quantifiers such as (a+)+, cannot be interrupted and can freeze the tab, so test risky patterns on short text first.
  • Other languages use slightly different regex flavors. Patterns that rely on features JavaScript lacks, such as possessive quantifiers, will fail or behave differently here.

Privacy and limits

The pattern and text are evaluated by your browser's RegExp engine and nothing is sent anywhere. Nothing is saved between visits, so reloading the page restores the starting example.

Back to the tool

§ 02 · common patterns

Eight patterns. Battle-tested defaults.

Email. The simple pragmatic version, not the full RFC 5322 monster. The pattern \b[\w.+-]+@[\w-]+\.[\w.-]+\b matches 99% of real email addresses. The full RFC 5322 regex is over 6,000 characters and matches things almost no real email service accepts. The pragmatic version is what every modern web framework actually uses.

URL. Matches http and https URLs with optional paths and query strings. Doesn't validate top-level domain or check the URL actually resolves, that's a different job. For URL-shape detection in user input or text scraping, this works. For URL parsing where you need the host, path, query separately, use the native URL constructor instead.

ISO date. Matches ISO 8601 dates, the date-only form (2026-05-02) and the full datetime form (2026-05-02T10:30:00Z and 2026-05-02T10:30:00.999Z). Capture groups break out the year, month, day, hour, minute, second. Doesn't validate calendar correctness, 2026-13-99 will match. Pair with a date library for that.

IPv4. Matches IPv4-shaped strings. Doesn't validate octet ranges (256.256.256.256 will match), that needs a stricter pattern with each octet bounded to 0-255 explicitly. For host-input validation, use the more careful pattern; for log scraping, this looser pattern is faster.

UUID v4. Strictly UUID v4, the version digit (4) and the variant bits (8, 9, a, b) are encoded in the pattern. UUIDs of other versions (v1 timestamp-based, v3/v5 hash-based) will not match. Useful for filtering log entries by UUID type or for validating session-token format.

Hex color. Matches #fff (3-digit), #ffffff (6-digit), and #ffffffff (8-digit with alpha). Useful for extracting color references from CSS or design tokens. Pair with our Color Contrast Checker to verify accessibility on the colors found.

URL slug. Anchored to start and end of line, matches only strings that are valid URL slugs (lowercase, digits, hyphen-separated, no leading or trailing hyphen). Useful for validating slug input. Pair with our Slug Generator for the generation side.

Phone (US/intl). Loose phone-shape detection, country code optional, area code with or without parens, hyphen / dot / space separators. Doesn't validate region or check the number actually exists; for that, use the official libphonenumber library.

§ 03 · when to use this

Four jobs this tool covers.

Job 1: Develop a regex against test data. Type your pattern, paste representative test data, watch matches highlight live. Iterate until the regex catches what you want and ignores what you don't. Once it works here, copy into your codebase. Catches mistakes early without the dev-loop overhead of saving and re-running the script.

Job 2: Debug a regex that's misbehaving in production. When a production regex matches too much or too little, paste it here with the failing input. The match-and-group panel shows exactly which substrings matched (or didn't), making it obvious which part of the pattern is wrong. Faster than adding console.log to your production code.

Job 3: Test rename / redact rules. Type your regex and a replacement string ($1, $2 references). The replace preview shows the transformed text live. Useful for testing log-redaction patterns before deploying, or for previewing a rename script before running it across a codebase. Pair with our Case Converter for case-shape rename rules.

Job 4: Learn regex by example. Click a preset, then study the pattern. The match panel shows what each capture group caught. Modify the pattern slightly, see what changes. The fastest way to internalise regex syntax is to play with patterns against representative input, and the only way to do that without a Node REPL is a regex tester.

§ 04 · questions

Six questions users ask.

Which regex flavor does this use?

JavaScript RegExp, the one used by Node, every browser, and most modern build tooling. Differs from PCRE (Perl / PHP / Python re) in a few notable ways: no possessive quantifiers, no atomic groups, lookbehind support added in ES2018 so it requires modern engines, named capture groups use (?<name>...) syntax. For PCRE-specific patterns (especially backtracking-control), test in your target language. For most standard patterns (email, URL, ISO date, slug), JS regex behaves identically to other flavors.

What do the six flags do?

g (global) finds all matches, not just the first; required for replace-all behavior. i (insensitive) ignores case so /apple/i matches APPLE. m (multiline) makes ^ and $ match line starts/ends rather than only string starts/ends. s (dotAll) makes . match newlines too, without s, . skips line breaks. u (unicode) enables full Unicode support including code-point aware matching for emoji and non-BMP characters. y (sticky) anchors matches at the lastIndex position only, used in tokenizers and parsers. Toggle each flag with the chip above the regex input.

How do capture groups work?

Parentheses in the regex pattern create capture groups. /(\w+)@(\w+\.\w+)/ captures two groups from email-shaped strings, the local-part and the domain. The matches panel shows each group's content and position. Named groups via /(?<user>\w+)@(?<domain>\w+\.\w+)/ assign labels you can reference in JavaScript via match.groups.user. Non-capturing groups (?:...) group for quantifier purposes without creating a capture slot, useful for performance and clarity.

What's the replace preview for?

Type a replacement string in the replace field. We run str.replace(regex, replacement) and show the result live. Replacement strings can use $1, $2, $3 to reference capture groups, $& for the full match, $` for content before the match, $' for content after. Useful for testing rename rules, redaction patterns, or text transformations before running the same regex against a real codebase or dataset.

Why does my regex run forever / freeze the page?

Catastrophic backtracking. Patterns with nested quantifiers like /(a+)+b/ or /(.*?)+x/ create exponential search spaces on input that doesn't match. The browser may freeze or take seconds-to-minutes on inputs over a few KB. We catch obvious infinite-loop conditions (timeout after 1 second), but the right fix is to rewrite the regex without nested quantifiers or to use atomic groups in PCRE flavors. A common rewrite: replace (a+)+ with a+ alone, or use possessive quantifiers if your engine supports them.

Is the text I paste sent anywhere?

No. Regex evaluation uses the browser's native RegExp object, runs entirely client-side. The page is static HTML; the only network request is the initial page load. Safe for sensitive log data, customer records, or any text you'd not want to upload to a third party.

Published · Last updated .

Priya sent you a message Online now

Talk to a Developer Now

Share your name and email to reply.

Reply