Skip to main content
NyankoTools

Regex Tester

Enter a regular expression pattern and some test text to see every match highlighted, along with a list of any capture groups. Add a replacement pattern to preview the result of a replace operation instantly. This tool follows JavaScript (ECMAScript) regular expression syntax. For plain string transformations, also try the HTML/JS String Escape & Unescape tool.

🔒 Runs in your browser · Your data is never sent to a server

//g

* The g (global) flag is always on so that every match can be shown.

Highlighted matches

Notes

  • Syntax follows JavaScript (ECMAScript) regular expressions, which differ in some details from other languages such as PHP, Python, or Java.
  • An invalid pattern, or a complex pattern prone to catastrophic backtracking, may temporarily freeze the browser. Be careful when testing against large amounts of text.
  • Everything runs entirely in your browser — the pattern and text you enter are never sent to a server.

Glossary

Regular expression

A notation for describing patterns in text, such as "one or more digits in a row" or "something that looks like an email address containing @". Short expressions like `\d+` or `[\w.]+@[\w.]+` can capture these conditions. Widely used for validation and for searching or replacing text.

Flags

Options that change how a regular expression behaves. `i` makes matching case-insensitive, `m` enables multiline mode (so `^` and `$` match the start/end of each line), `s` makes `.` also match newlines, and `u` enables Unicode mode (correct handling of surrogate pairs and `\u{}` escapes).

Capture group

Wrapping part of a pattern in `(...)` lets you extract just that matched portion. For example, `(\d+)-(\d+)` captures the first and second runs of digits separately. A group written as `(?<name>...)` is called a "named capture group".

Replacement pattern

The syntax used to build the replacement text for a match. `$1`, `$2` refer to capture groups by position, and `$<name>` refers to a named capture group. For example, replacing matches of `(\d+)-(\d+)` with `$2/$1` swaps the two numbers around.

FAQ

Which regex flavor does it use?

It follows JavaScript (ECMAScript) regular expressions. Lookbehind support, flags and some syntax can differ from PHP, Python or Java.

Can the browser freeze?

Patterns that cause catastrophic backtracking can make the browser hang temporarily. Simplify the pattern when testing against large text.

Can I preview replacements?

Yes. Enter a replacement pattern to preview the result instantly, and refer to capture groups with $1, $2 and so on.

Share this page

↑↓ Select Enter Open Esc Close