Examples

Find email-like strings globally

Input
Pattern: \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b
Flags: g
Text: Write to dev@example.com or ops.team+alerts@sub.example.org; ignore user@.com.
Output
[
  {
    "match": "dev@example.com",
    "index": 9
  },
  {
    "match": "ops.team+alerts@sub.example.org",
    "index": 28
  }
]

The global flag returns both complete matches; the malformed user@.com substring does not satisfy the domain portion.

Inspect numbered and named capture groups

Input
Pattern: (?<year>\d{4})-(\d{2})-(\d{2})
Flags: g
Text: Releases: 2026-01-15 and 2026-07-01.
Output
[
  {
    "match": "2026-01-15",
    "index": 10,
    "captures": ["2026", "01", "15"],
    "groups": { "year": "2026" }
  },
  {
    "match": "2026-07-01",
    "index": 25,
    "captures": ["2026", "07", "01"],
    "groups": { "year": "2026" }
  }
]

The year is available as both capture 1 and the named year group; month and day are captures 2 and 3.

Compare single, global, and case-insensitive matching

Input
Pattern: error
Text: Error: one
error: two
error: three
ERROR: four
Output
no flags: ["error"]
g:        ["error", "error"]
gi:       ["Error", "error", "error", "ERROR"]

Without g, JavaScript stops after the first case-sensitive match; g finds every case-sensitive match, and i adds case-insensitive matching.

About this tool

A regular expression is a compact language for describing text patterns — used everywhere from form validation and log parsing to search-and-replace and data extraction. This tester lets you build a pattern and see exactly what it matches, character by character, as you type. Matches are highlighted directly inside your test string and broken down into capture groups, named groups, and positions.

The engine is the browser's native JavaScript (ECMAScript) RegExp, so results are identical to what your JavaScript or Node.js code will do at runtime — no surprises between the tester and production. Matching runs in a Web Worker with a timeout, so even a pathological pattern that would normally freeze the tab is stopped safely and reported as a likely catastrophic-backtracking case.

Everything is client-side: your pattern and test data never leave the browser. Switch to Substitution mode to preview find-and-replace with $1 / $<name> references, load a sample to learn a new construct, or copy the shareable link to send a working pattern to a teammate — the pattern, flags, and test text are all encoded in the URL.

How to use

  1. Write a pattern and see live matches

    Type a regular expression in the editor; it is syntax-highlighted as you go. Every match is highlighted in the Test String preview and listed with its offsets in the Match Information panel below.

  2. Toggle flags

    Click the g, i, m, s, u, and y buttons to switch flags on and off. Global (g) finds all matches; insensitive (i) ignores case; multiline (m) changes ^ and $; dotAll (s) lets . match newlines.

  3. Inspect capture groups

    Hover a match to link it to its entry in the Match Information panel, which shows each numbered and named capture group with its value and position.

  4. Replace with substitution

    Open the Substitution tab and enter a replacement using $1, $<name>, or $& to reference matches. The replaced output previews live and can be copied.

  5. Share a pattern

    Click 'Copy link' to copy a URL that encodes the pattern, flags, and test text so anyone can open the exact same setup.

Use cases

Validating input formats

Prototype JavaScript patterns for identifiers, dates, email-like strings, or version numbers before moving the pattern into client or server validation code.

Extracting structured data from logs

Use numbered or named groups to pull timestamps, status codes, request IDs, and paths from representative log lines and inspect every match offset.

Designing search-and-replace rules

Preview substitutions with $1, $<name>, or $& before applying a bulk refactor or cleanup to source files and datasets.

Reproducing a regex bug

Share the encoded pattern, flags, and test text with a teammate so both people debug the same JavaScript RegExp behavior.

Common regex tokens

TokenMatches
\d \w \sA digit, a word character, or whitespace
.Any character (any except newline unless the s flag is set)
* + ?Zero-or-more, one-or-more, or optional (zero-or-one)
{n} {n,} {n,m}Exactly n, at least n, or between n and m repetitions
^ $ \bStart of input/line, end of input/line, a word boundary
[abc] [^abc]Any one listed character / any character not listed
(…) (?:…) (?<name>…)Capturing, non-capturing, and named groups
(?=…) (?!…)Positive and negative lookahead
a|bAlternation — match a or b

Uses the JavaScript (ECMAScript) regex flavor — the same engine your browser and Node.js run.

Common mistakes

Mistake:Forgetting that ., *, (, ), and other metacharacters have special meanings.

Fix:Escape syntax characters when they must be literal, such as \. for a dot and \( for an opening parenthesis. When building a RegExp from a JavaScript string, remember the string layer may require an additional backslash.

Mistake:Using greedy .* for a bounded field or omitting anchors when the whole input must match.

Fix:Prefer a specific character class or a lazy quantifier where appropriate, and add ^ and $ when partial substring matches should be rejected.

Mistake:Testing catastrophic-backtracking patterns only on short successful input.

Fix:Test long near-misses as well as matches, avoid ambiguous nested quantifiers, and simplify overlapping alternatives. The tester's timeout is a warning, not proof that a pattern is safe at production scale.

Mistake:Expecting repeated exec-style matching without the g flag, or expecting g to make matching case-insensitive.

Fix:Use g to iterate through all matches and i independently for case-insensitive matching. Treat flags as separate behavior switches.

Frequently asked questions

References & standards