Toolminex
Developer Tool

Regex Validator

Test JavaScript regular expressions against sample text, inspect live matches, review capture groups, and preview replacement output. Free, private, and built for fast debugging.

Runs in browserLive match previewFree & no signup

Regex pattern

Flags

Test text

Validation result

Valid regex

Matches

3

Highlighted text

Contact [email protected] for product questions. For billing, email [email protected] or [email protected]. Invalid examples: support@, @example.com, and plain text.

Matches and groups

Match 1index 8
[email protected]
Match 2index 72
[email protected]
Match 3index 95
[email protected]

Replace preview

Contact [email hidden] for product questions.
For billing, email [email hidden] or [email hidden].
Invalid examples: support@, @example.com, and plain text.

How to test a regular expression

Write a pattern, choose flags, and see every match, group and replacement on your own text.

  1. 01

    Write the pattern without slashes

    Type the part between the slashes only, such as \d{4}-\d{2}-\d{2}, not /\d{4}/. The sample pattern finds email addresses so you can see the output first.

  2. 02

    Switch on the flags you need

    g finds every match instead of the first, i ignores case, m makes ^ and $ work per line, s lets . match line breaks, u turns on full Unicode, and y anchors each match where the last ended.

  3. 03

    Paste test text and read the matches

    Each match shows its position in the text and any capture groups. If the pattern itself is invalid, the error message from the JavaScript engine appears instead.

  4. 04

    Try a replacement

    The replacement box previews String.replace on your text. Use $1, $2 for numbered groups and $<name> for named ones.

Worked examples

The sample pattern, \b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}\b with the g and i flags, run on "Contact [email protected] or [email protected] today." finds two matches: [email protected] at position 8 and [email protected] at position 33. Without the i flag it finds none, because the character classes only list capital letters.

Replacements can rearrange what they capture. The pattern (\d{4})-(\d{2})-(\d{2}) with the replacement $3/$2/$1 turns 2026-10-31 into 31/10/2026. Each pair of brackets is a group, numbered from the left.

What each flag changes

Flags change how the whole pattern behaves. The same pattern can match everything, nothing or something in between depending on them.

FlagEffectTypical use
g (global)Find all matches, not just the firstCounting or highlighting every email in a page
i (ignore case)A matches a, É matches éMatching words regardless of capitals
m (multiline)^ and $ match at each line, not just the whole textChecking every line of a log is a number
s (dot all). also matches line breaksGrabbing a block that spans lines
u (unicode)Treats emoji and other astral characters as one character; enables \p{…}Matching \p{L} letters in any language
y (sticky)Each match must start exactly where the last one endedWriting a tokenizer

The m flag catches people out most. ^\d+$ tested against "12" then a new line and "ab" fails without m, because the whole text isn't digits. With m it succeeds, because the first line on its own is.

Where regex testing saves time

Writing form validation

Test a pattern against the inputs you expect and the ones you don't, before it rejects real customers' postcodes or names.

Search and replace in an editor

VS Code and most editors use the same syntax. Check the pattern and the $1 replacement here, then paste both in.

Pulling values out of logs

Capture IDs, status codes or timestamps with groups, and check the matches on a few sample lines first.

Limits and pitfalls

This is JavaScript's regex engine. Most syntax is shared with Python, Java and PCRE, but not all: possessive quantifiers like a++ and atomic groups (?>…) aren't supported, and lookbehind works in modern browsers but not in some older engines. Test in the language you'll deploy to if it isn't JavaScript.

Some patterns take exponential time on certain inputs, known as catastrophic backtracking. ^(a+)+$ against 27 a's followed by a b took about 3.7 seconds to fail in our test, and each extra a roughly doubles it. The page runs the pattern directly, so a pattern like that will freeze the tab while it works. Avoid nesting quantifiers such as (a+)+ or (.*)*.

  • Only the first 100 matches are listed.
  • A pattern that matches empty text, such as a*, reports only its first match.

Frequently asked questions

No. The pattern runs in your browser with the built-in RegExp object.
Usually a syntax difference: Python's (?P<name>…) groups are written (?<name>…) in JavaScript, and inline flags such as (?i) aren't supported. Use the flag checkboxes instead.
Escape it with a backslash: \. matches a dot and \( a bracket. Inside a character class, most characters are literal, so [.] also works.
Only loosely. A strict pattern either rejects real addresses or accepts invalid ones. Check for one @ and a dot in the domain, then confirm by sending an email.
Greedy quantifiers like .* take as much as they can; lazy ones like .*? take as little as possible. On <b>x</b><b>y</b>, <b>.*</b> matches the whole string while <b>.*?</b> matches just <b>x</b>.

Related developer tools

Something not working right?