Skip to content
uxTools
Developer

Regex Tester + Cheatsheet

Test JavaScript regular expressions, inspect named groups, preview replacements, load common patterns, and get warnings for risky backtracking.

Regex status

Ready

/(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g

Matches shown

2

Showing the first 2 matches to keep the panel fast.

Performance risk

Low

Heuristic score: 0

Replace preview

Changed

6 numbered captures • 6 named captures

Editor

Runs with the browser's native JavaScript RegExp engine. Type a pattern, toggle flags, and test against any input.

Flags

Results

See live matches, capture groups, and the replacement output side by side.

Replace preview

Output changed after replacement.

Literal: /(?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2})/g
Release 02/05/2026
Patch 15/06/2026

Match list

Showing 2 matches
Match 1index 8–18
2026-05-02

Numbered groups

  • $12026
  • $205
  • $302

Named groups

  • year2026
  • month05
  • day02
Match 2index 25–35
2026-06-15

Numbered groups

  • $12026
  • $206
  • $315

Named groups

  • year2026
  • month06
  • day15

Match extractor / export

List every match with its capture groups, then export the set as JSON or CSV.

2 matches ready to export

Output is capped to keep the panel fast; turn off `g`/`y` or trim the input to see fewer matches.

{
  "count": 2,
  "truncated": true,
  "matches": [
    {
      "match": "2026-05-02",
      "index": 8,
      "groups": [
        "2026",
        "05",
        "02"
      ],
      "named": {
        "year": "2026",
        "month": "05",
        "day": "02"
      }
    },
    {
      "match": "2026-06-15",
      "index": 25,
      "groups": [
        "2026",
        "06",
        "15"
      ],
      "named": {
        "year": "2026",
        "month": "06",
        "day": "15"
      }
    }
  ]
}

Performance warnings

These checks are heuristic, not a full regex proof. They are designed to catch the most common catastrophic backtracking shapes before they freeze the tab.

Current riskLow

No obvious backtracking traps were detected for the current pattern.

Common patterns library

Load a production-style pattern with sample input and a ready-made replacement template.

Quick cheatsheet

A compact refresher for the tokens and replacement helpers you reach for most often in JavaScript regex.

Flags

g

Find every match instead of stopping at the first one.

i

Make letter matching case-insensitive.

m

Let `^` and `$` work per line instead of only at the start/end of the whole string.

s

Allow `.` to match newline characters too.

u

Enable Unicode-aware escapes and code point handling.

y

Match only from the current `lastIndex` position.

Anchors

^

Start of string, or start of line with `m`.

$

End of string, or end of line with `m`.

\b

Boundary between word and non-word characters.

\B

Position that is not a word boundary.

Character classes

\d

Any ASCII digit from 0 to 9.

\w

Word character: letters, digits, and underscore.

\s

Space, tab, newline, and other whitespace characters.

[A-Z0-9_]

Custom set: match one character from the listed range.

Quantifiers

*

Repeat the previous token zero or more times.

+

Repeat the previous token one or more times.

?

Make the previous token optional.

{m,n}

Repeat between `m` and `n` times.

Groups

(...)

Create a numbered capture you can reuse in output.

(?<name>...)

Create a named capture such as `year` or `slug`.

(?:...)

Group tokens without creating a capture slot.

foo|bar

Match either the left branch or the right branch.

Lookarounds

(?=...)

Require the next characters without consuming them.

(?!...)

Require that the next characters do not match.

(?<=...)

Require previous characters without consuming them.

(?<!...)

Require that previous characters do not match.

Replacement tokens

$&

Insert the full matched text.

$1

Insert capture group 1, 2, 3, and so on.

$<name>

Insert a named capture replacement from the current match.

$`

Insert the text that appears before the match.

$'

Insert the text that appears after the match.

Notes

A few practical reminders that help when you're debugging real regexes.

  • Named groups and replace preview use modern JavaScript syntax, so what you see here matches the browser `RegExp` engine.
  • If you expect multiple matches, turn on `g`; otherwise JavaScript stops after the first successful match.
  • Heuristic risk warnings are conservative. They are meant to keep the tester responsive, not to formally prove a regex safe or unsafe.