Skip to content

Regex Tester

Test JavaScript regular expressions live.

Runs in your browser · free · no sign-up

Matches: 2
Contact: ali@example.com, sara.k@mail.pk Not an email: hello@ world
#MatchIndexGroups
1ali@example.com9—
2sara.k@mail.pk26—
Cheat sheet

About the Regex Tester

Write a pattern, set the flags and see every match highlighted in your sample text as you type. Capture groups for each match are listed below, which makes it easy to build and debug patterns for validation or search-and-replace.

Regular expressions are compact patterns for finding and changing text: validating an email field, pulling order numbers out of a log, or renaming hundreds of lines in an editor. They are powerful but easy to get subtly wrong, and a pattern that looks right can miss half the cases. This tester lets you see the effect of every change immediately.

Type a pattern and choose flags, then paste sample text. Every match is highlighted, and the capture groups for each match, including named groups, are listed underneath. An optional replacement field shows the result of a replace using $1 or $<name> references, the same syntax as JavaScript’s String.replace. Because it uses the browser’s own engine, a pattern that works here behaves the same in front-end code and Node.js.

How to use the Regex Tester

  1. 1Enter your pattern without the slashes.
  2. 2Tick the flags you need (g, i, m, s, u).
  3. 3Paste test text and review the highlighted matches and groups.

Key features

  • Live highlighting of all matches.
  • Capture groups listed for every match, with its position.
  • Flags g, i, m, s and u.
  • Replace preview with $1 and $<name> references.
  • Clear error messages for invalid patterns.

Practical uses

  • Building validation for phone numbers, postcodes or IDs.
  • Extracting values from logs before writing a script.
  • Preparing search-and-replace patterns for VS Code.
  • Learning regex by experimenting with real text.

Example

The pattern (\d{4})-(\d{2})-(\d{2}) with the g flag highlights every ISO date in your text. With the replacement $3/$2/$1, the preview turns 2026-10-31 into 31/10/2026.

Tips and common mistakes

  • Escape dots with \. when you mean a literal full stop.
  • Use ^ and $ with the m flag to match at the start and end of each line.
  • Prefer specific character classes like [^,]+ over .* to avoid matching too much.
  • Test with examples that should fail as well as ones that should match.

Limitations

  • Only JavaScript regex syntax is supported; features specific to PCRE or Python, such as possessive quantifiers, may not work.
  • Extremely slow patterns on large text can freeze the tab for a moment.

Privacy

Your pattern and test text stay in the browser. You can test against real log lines without them being uploaded.

Frequently asked questions

Which regex flavour is used?

JavaScript (ECMAScript) regular expressions, the same as in browsers and Node.js.

Why do I only see one match?

Turn on the g (global) flag to find all matches instead of the first one.

What does the s flag do?

It lets the dot (.) also match line breaks.

Do I include the slashes?

No. Type only the pattern itself and set flags with the checkboxes.

Related tools

JSON FormatterFormat, validate and minify JSON.
Base64 Encoder / DecoderEncode text to Base64 or decode it back.
URL Encoder / DecoderPercent-encode or decode URLs and query values.
JWT Decoder & BuilderNewDecode a JWT, check expiry, and sign HS256 test tokens.