🔒 Runs in your browser — nothing is uploaded✓ Free, no signup

Regex Tester — Test JavaScript Regular Expressions

Type a pattern and see every match highlighted as you type. Inspect capture groups, toggle flags and preview replacements — all in your browser.

//g
Presets:

Matches (2 found)

Contact ada@example.com or grace.hopper@navy.mil
Released 2026-10-09, patched 2026-11-01
Visit https://trueformatter.com/regex-tester from 192.168.1.20
Brand colors: #7c3aed and #fff

Match details

#MatchIndex
1ada@example.com8
2grace.hopper@navy.mil27

When should you use the Regex Tester?

  • Writing a validation pattern for emails, phone numbers or IDs
  • Extracting values from logs or text with capture groups
  • Checking a search-and-replace before running it on real data

How to use the Regex Tester

  1. 1

    Enter a pattern

    Type your regex in the pattern box without the surrounding slashes, or click a preset to start from a common pattern.

  2. 2

    Pick flags

    Tick g to find every match, i to ignore case, m for line-by-line ^ and $, s so . matches newlines, and u for Unicode.

  3. 3

    Paste test text

    Matches are highlighted on the right and listed with their index and capture groups below.

  4. 4

    Try a replacement

    Turn on Replace and use $1 or $<name> to rearrange matched text, then copy the result.

Examples

Named groups for dates

Pattern + text

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

Released 2026-10-09

Groups

match: 2026-10-09
year:  2026
month: 10
day:   09

Reformat with replace

Replacement

Pattern:     (\d{4})-(\d{2})-(\d{2})
Replacement: $3/$2/$1

Result

2026-10-09  →  09/10/2026

Common errors and how to fix them

Invalid regular expression: Unterminated group
A ( has no matching ). Close the group, or escape it as \( if you meant a literal parenthesis.
Nothing to repeat
A quantifier (* + ? {n}) has nothing before it, e.g. a pattern starting with *. Escape it as \* for a literal asterisk.
Only the first match is found
Turn on the g (global) flag.
^ and $ only match the whole text
Turn on the m (multiline) flag so they match at the start and end of every line.
. does not match across lines
Turn on the s (dotAll) flag, or use [\s\S] instead of the dot.
Related tools: JSON Validator · URL Encoder & Decoder · Hash Generator

Explore More Developer Tools

Format, Validate, and Generate Data Instantly

TrueFormatter provides essential utilities for modern web development, including JSON formatting, YAML conversion, and more.

JSON Auto-Fixer & Formatter

Repair, validate, and beautify broken JSON (missing quotes, trailing commas).

JSON Validator & Linter

Check JSON syntax and see the exact line and column of every error.

JSON Beautifier

Pretty-print and indent JSON for easy reading and debugging.

JSON Compare & Diff Tool

Find the difference between two JSON objects visually and quickly.

JSONPath Tester

Evaluate JSONPath expressions with filters and recursive queries.

JSON Schema Generator

Generate a JSON Schema from any sample JSON document.

JSON to CSV Converter

Flatten nested JSON arrays into CSV for spreadsheets.

YAML ⇆ JSON Converter

Convert YAML to JSON or JSON to YAML instantly.

JWT Decoder

Decode and inspect JSON Web Tokens (JWT) Header and Payload.

JWT Generator

Create and sign HS256/HS384/HS512 JSON Web Tokens for testing.

Hash Generator (MD5, SHA)

Generate MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashes.

Base64 Encoder ⇆ Decoder

Encode text to Base64 and decode Base64 to text for API debugging.

URL Encoder & Decoder

Cleanly encode special characters in URLs and decode query strings.

SQL Formatter & Beautifier

Format SQL queries for MySQL, PostgreSQL, SQL Server, SQLite and more.

CSS Minifier & Compressor

Optimize CSS by removing whitespace and comments to accelerate page load time.

JS Minifier & Compressor

Compress JavaScript to improve website speed and performance.

Regex Tester & Debugger

Test JavaScript regular expressions with live match highlighting and groups.

Cron Expression Generator

Build cron schedules, read them in plain English and preview next runs.

UUID / GUID Generator

Generate unique V4 UUIDs for database keys or testing.

Epoch converter online

Convert UNIX timestamps to human-readable dates and back instantly.

Crop Image Online

Crop images exactly as selected with fixed aspect ratios. No upload, no resize, no quality loss.

Compress Image Online

Compress JPG, PNG & WebP images directly in your browser. No upload, no tracking, instant download.

Regex Tester FAQ

JavaScript (ECMAScript) regular expressions, using your browser's built-in RegExp engine. Results match what you get in Node.js, Chrome, Firefox and Safari.

g finds all matches instead of the first, i ignores case, m makes ^ and $ match at each line, s lets . match newlines, and u enables full Unicode matching including \p{...} property escapes.

Wrap part of the pattern in parentheses, e.g. (\d{4})-(\d{2}). Each group appears as its own column in the match details table. Name a group with (?<year>\d{4}) to see its name.

Turn on Replace and use $1, $2 for numbered groups, $<name> for named groups, $& for the whole match and $$ for a literal dollar sign.

Without the g (global) flag JavaScript stops after the first match. Tick the global checkbox to find every match.

Common causes are an unescaped special character such as ( [ { + * ? . or \, an unclosed group, or lookbehind syntax in an old browser. The error message under the pattern explains the problem.