BrowserLeaksUSBrowserLeaksUS

Regex Tester

Test regular expressions in real-time - fully client-side

Regex Tester

//
0 matches

What this tool does

Interactive regex tester - type a pattern and see matches highlighted in real time. Supports flags (g, i, m, s, u), displays capture groups, and shows the match count. Fully client-side using the browser's native regex engine.

Who it's for: Developers crafting validation patterns, data analysts building log parsers, and anyone debugging a finicky regex.

When to use

  • •Test a regex against sample text before shipping code.
  • •Debug why a validation pattern rejects valid input.
  • •Extract capture groups from log lines.
  • •Experiment with regex flags to see behavior changes.

How it works

  1. 1Paste test text in the content area.
  2. 2Type your regex and toggle flags.
  3. 3Matches are highlighted; capture groups are listed.
  4. 4Runs entirely in-browser - no data upload.

Tips

  • •JavaScript regex lacks some Perl features (possessive quantifiers, conditionals).
  • •Use the u flag for proper Unicode matching.
  • •Always anchor (^ and $) when validating whole-string input.

Using this result

How to read the regex tester

01

Matches, groups, and flags

The pattern box is a JavaScript regular expression. The test text is the string it runs against. Highlighted spans are matches. A capture group is the part of a match inside parentheses, and it appears in the group list as a number. Named groups appear under the name you wrote with ?<name>. Group 0 is the whole match. If the pattern compiles but nothing highlights, the pattern is valid and the text does not contain it. An error above the pattern is a syntax error, not a failed search.

Flags change the engine. g finds every match rather than the first. i ignores case. m makes ^ and $ match line boundaries. s lets a dot match a newline. u turns on Unicode mode, which you want for text outside ASCII. v is the newer Unicode set mode. A pattern copied from another language can fail here because lookbehind, possessive quantifiers, or a different escape is not the JavaScript flavor. The substitution box shows the replacement with $1 and named groups expanded. It does not modify a file.

02

Reading a surprising match

A pattern that matches more than you expected is usually greedy. .* will run to the end of the line and then backtrack. Use a more specific class, or a non-greedy .*?, and look at which span is highlighted. Anchors are the other common miss. Without ^ and $, a search succeeds when the pattern appears anywhere. Email and URL checks that are not anchored will accept a sentence that merely contains an address.

The preset library is a starting point, not a validator. An email preset does not prove an address exists. A date preset does not prove the date is real. Use Regex Generator when you want a pattern drafted from a description, then come back here and throw real samples at it, including the samples that should fail. A pattern that only ever sees the happy path will ship broken.