Regex tester

Test a regular expression against your text and see what each part means.

Flags

2 matches

Released 2026-10-15, patched 2026-11-02. Not a date: 2026-13-40.
/(?<year>\d{4})-(?<month>0[1-9]|1[0-2])-(?<day>0[1-9]|[12]\d|3[01])/g

Matches

  1. 12026-10-159–19
    year
    2026
    month
    10
    day
    15
  2. 22026-11-0229–39
    year
    2026
    month
    11
    day
    02

What the pattern means

  • (?<year>Group 1, named “year”
  • \d{4}A digit (0–9), exactly 4 times
  • )End of group
  • -The character -
  • (?<month>Group 2, named “month”
  • 0The character 0
  • [1-9]A character from 1–9
  • |Or
  • 1The character 1
  • [0-2]A character from 0–2
  • )End of group
  • -The character -
  • (?<day>Group 3, named “day”
  • 0The character 0
  • [1-9]A character from 1–9
  • |Or
  • [12]One of: 1, 2
  • \dA digit (0–9)
  • |Or
  • 3The character 3
  • [01]One of: 0, 1
  • )End of group

What it does

Write a regular expression and see straight away what it matches: every match is highlighted in your text and listed with its position, numbered groups and named groups. The pattern is also explained piece by piece in plain English, so a line like (?<year>\d{4})-(\d{2}) reads as “group 1, named year: a digit, exactly 4 times” instead of a puzzle. Replace mode shows the result of a search-and-replace with $1, $<name> and $& as you type. Matching uses your browser’s own JavaScript engine, the same one that runs your front-end and Node.js code, so what works here works there. A badly written pattern can take minutes to run on some text (catastrophic backtracking); here it’s stopped after 1.5 seconds with an explanation, instead of freezing the page.

How to use it

How it works
  1. Type your pattern between the slashes, or start from one of the examples. Turn flags on or off below it: g finds every match, i ignores case, m makes ^ and $ work per line.
  2. Paste the text to test. Matches are highlighted as you type, and each one is listed with its position and capture groups.
  3. Read “What the pattern means” to check each part of your regex in plain English.
  4. To replace, switch on “Replace” and write the replacement, using $1 or $<name> for groups. Copy the result, or copy the regex itself for your code.

Common uses

  • Writing a validation pattern for a form field and checking it against good and bad examples
  • Pulling dates, IDs or email addresses out of a log file or a pasted report
  • Understanding a regex someone else wrote before changing it
  • Testing a find-and-replace with capture groups before running it on a whole codebase

Tips

  • Without the g flag, JavaScript stops at the first match. That’s what String.prototype.match and RegExp.exec do in your code too.
  • Nested quantifiers like (a+)+ or (\w+\s?)* can backtrack exponentially on text that almost matches. Make each part match something distinct, or use a character class instead of alternation.
  • Named groups, (?<name>…), make replacements readable: $<year>-$<month> is easier to check than $2-$1.

Questions

Which regex flavor does it use?

JavaScript (ECMAScript), run by your browser. It matches what JavaScript, TypeScript and Node.js do. PCRE (PHP), Python and Java are close but not identical: for example, JavaScript has no possessive quantifiers or atomic groups, and lookbehind and \p{…} classes only work in modern engines.

Why does my pattern time out?

Some patterns try an enormous number of ways to match before failing, usually because of nested repetition such as (a+)+ or overlapping alternatives. The tester stops after 1.5 seconds so the page keeps working. The same pattern could freeze a server, so it’s worth rewriting.

Is my text sent anywhere?

No. Matching runs in a background worker inside your browser, and your pattern and text are never uploaded or saved.

What do the u and y flags do?

u (unicode) treats emoji and other characters outside the basic range as single characters and enables \p{…} classes such as \p{Script=Arabic}. y (sticky) only matches at the exact position where the previous match ended, which is mostly useful in tokenizers.

Related tools

  • JSON formatter and validator

    Format, validate and minify JSON in your browser. Clear errors with line and column, big numbers kept exact, duplicate keys flagged. No upload.

  • JWT decoder and verifier

    Decode a JWT to read its header, payload and expiry, and check its signature with a secret or public key. Runs in your browser; the token stays private.

  • Base64 encoder and decoder

    Encode text or files to Base64 and decode Base64 back, with proper UTF-8, URL-safe Base64 and file detection. Free, in your browser, no upload.

  • URL encoder and decoder

    Percent-encode text for URLs and query strings, or decode %20-style escapes back to text. Handles UTF-8, + for spaces and splits URLs into parts.

  • UUID generator

    Generate UUID v4 or v7 values, one or a thousand at once, with the browser’s secure random generator. Check any UUID’s version and creation time.

  • Hash generator and checksum checker

    Calculate MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes of text or files, and check a download against its checksum. In your browser, no upload.