Regex Tester

Test regular expressions with real-time matching, replacement, and split operations

  • 100% Free
  • Files stay private
  • Works in your browser
Try it now·Regex Tester
//g
Flags
matches update live

Enter a regular expression to begin.

Uses your browser’s native JavaScript RegExp engine, so results match your app exactly. Everything runs locally. Your pattern and text never leave your device.

How it works

  1. Write your pattern

    Type a pattern into the Regular expression field, or pick one from Presets, then paste your Test text.

  2. Set flags and mode

    Toggle flags such as g or i, then choose Match, Replace or Split to decide what to preview.

  3. Preview the outcome

    Match highlights the hits and lists Match details. Replace swaps in what you type under Replacement, with a Result you can Copy. Split lists the parts.

Build, test, and debug regular expressions with live highlighting, capture-group details, and replace and split previews, powered by your browser's own JavaScript engine.

What is Regex Tester?

A regular expression is a compact pattern for finding, extracting, or transforming text. This tester lets you write a pattern, toggle flags, and instantly see what it matches against your own sample text. Because it uses the native JavaScript RegExp engine, the behaviour you see here is exactly what your Node.js or browser code will do.

Who Benefits from This Tool

  • Web developers validating form fields, parsing input, or scraping structured data.
  • Data analysts cleaning messy text and pulling out emails, dates, or IDs.
  • Content editors running find-and-replace across large blocks of copy.
  • Students learning regex who want immediate, visual feedback on each pattern.
  • DevOps and sysadmins testing log-filtering and grep-style expressions safely.

Key Features

  • Live matching: highlights every match in your test text as you type, with no run button needed.
  • Three modes: switch between Match, Replace, and Split to explore what the pattern does.
  • Full flag control: toggle g, i, m, s, u, and y individually, with a plain-English tooltip on each.
  • Capture-group inspection: a detail table shows each match's index, length, and numbered or named groups.
  • Replacement preview: supports $1, $<name>, and $& substitutions with a live result count.
  • Ready-made presets: a searchable library of common patterns (email, URL, phone, IP, dates, hex colours, slugs, and more).
  • One-click sample: load an example pattern and text to see the tool in action instantly.

How to Use

  1. Type your pattern into the expression field, or pick one from the presets menu.
  2. Toggle the flags you need: g for all matches, i to ignore case, and so on.
  3. Paste the text you want to test into the test-text box; matches highlight immediately.
  4. Switch to Replace or Split mode to preview transformations of the same input.
  5. Copy the replaced text or the split parts straight from the result panel.

Common Use Cases

  • Validating that an email, phone number, or postal code follows the expected format.
  • Extracting all URLs, hashtags, or dates from a block of unstructured text.
  • Rewriting text with capture-group references, like reformatting names or dates.
  • Splitting a CSV-like or delimited string into clean parts.
  • Debugging a stubborn production regex by isolating it against real sample data.

Tips and Best Practices

  • Use named groups like (?<year>\d{4}) to make complex patterns readable and self-documenting.
  • Prefer specific character classes over a broad dot to avoid accidental over-matching.
  • Watch for catastrophic backtracking: nested quantifiers on large inputs can be extremely slow.
  • Remember the g flag is required in Match mode to see every occurrence, not just the first.
  • Test edge cases (empty strings, unicode characters, and line breaks) before trusting a pattern in production.

Limitations and Notes

This tester uses the JavaScript flavour of regular expressions, which differs from PCRE, Python, or .NET in some syntax details. Lookbehind support, for example, depends on your browser. Everything runs locally, so your pattern and text never leave your device. For performance, matches are capped at a large limit on very big inputs; if you hit it, the tool tells you it's showing the first results.

FAQs

It uses your browser's native JavaScript RegExp engine, so results match exactly what runs in JavaScript and Node.js applications.

g finds all matches, i ignores case, m makes ^ and $ match line boundaries, s lets the dot match newlines, u enables full unicode handling, and y anchors matching to a sticky position. Each toggle has a tooltip explaining it.

No. All matching, replacing, and splitting happens in your browser. Your pattern and test text are never transmitted.

Yes. In Replace mode you can reference numbered groups with $1, named groups with $<name>, and the whole match with $&.

When your browser supports match indices, the tool reports the starting position of each capture group so you can see exactly where it landed in the text.

Those depend on your browser's regex support. Modern browsers handle both, but very old ones may not. The tool will surface a syntax error if a feature isn't available.

More Development Tools

Other tools in Development Tools.

All Development Tools