Skip to content
ToolHive

Regex Tester

Test regular expressions against real text with live highlighting, capture groups, match positions and a replace preview. Uses your browser's own JavaScript engine, so what you see is exactly what your code will do.

Regex Tools

How to use Regex Tester

  1. Type your pattern between the slashes at the top.
  2. Toggle the flags you need: g, i, m, s, u and y are all available.
  3. Paste the text to search into the left panel; matches highlight on the right as you type.
  4. Open the match table to see each match's index and capture groups.
  5. Turn on Replace mode to preview a replacement using $1, $& or $<name>.

Examples

Capture groups

Parentheses capture. This splits an email into its local part and domain.

([\w.+-]+)@([\w-]+(?:\.[\w-]+)+)

Find a repeated word

A back-reference matches the same text the group captured, which finds accidental duplicates.

\b(\w+)\s+\1\b

Strip trailing whitespace

With the m flag, $ matches at every line ending rather than only at the end of the text.

[ \t]+$      flags: gm

Features

  • Live matching with every match highlighted in the subject text
  • All six JavaScript flags with a plain-English label for each
  • Match table with index, full match and every numbered and named capture group
  • Replace mode with a live preview, supporting $1, $&, $` and $<name>
  • Invalid patterns report the engine's message instead of crashing
  • Zero-length matches are handled without an infinite loop
  • Five worked examples: email, ISO date, hex colour, duplicate word, trailing space
  • Copy the finished /pattern/flags in one click

Frequently asked questions

Which regex flavour is this?
JavaScript's, because the pattern is compiled with your browser's own RegExp. That makes it exact for JavaScript and TypeScript work, but PCRE, Python and Go differ in places — notably lookbehind support and named-group syntax.
What does each flag do?
g finds every match rather than the first; i ignores case; m makes ^ and $ match at line breaks; s lets . match newlines; u enables full Unicode and \p{...} property escapes; y anchors each match at lastIndex.
Why does my pattern match nothing?
The most common causes are a missing g flag when you expect several matches, an unescaped special character such as . or ?, or ^ and $ without the m flag on multi-line text.
How do I use capture groups in a replacement?
$1 is the first group, $2 the second, $& the whole match, and $<name> a named group written as (?<name>...). Replace mode previews the result live.
Is there a limit on matches?
The first 2,000 matches are collected and the first 200 listed in the table, which keeps the page responsive on large inputs. The count tells you when that limit was reached.
Does my text leave the browser?
No. The pattern is compiled and run locally, so both the expression and the text you test stay in the tab.

Related tools

About Regex Tester

Regex Tester is part of Regex Tools on ToolHive, a growing collection of small, focused utilities for developers, designers and students. Write, test and understand regular expressions with live match highlighting. Everything runs client-side, so your data never leaves the browser tab — which makes these tools safe to use with work-in-progress code and private content.