Skip to content

Regex Tester

Write a regular expression and see every match highlighted as you type.

//
Matches highlighted
Cheat sheet and common patterns
TokenMeaning
\dAny digit 0–9
\wLetter, digit or underscore
\sWhitespace (space, tab, newline)
.Any character except newline
^ / $Start / end of string (or line with m)
\bWord boundary
[abc] / [^abc]One of / none of these characters
a* / a+ / a?0 or more / 1 or more / optional
a{2,4}Between 2 and 4 times
(…) / (?:…)Capturing / non-capturing group
(?<name>…)Named group
a|ba or b
(?=…) / (?!…)Followed by / not followed by
$1, $<name>Group in the replacement

Click a pattern to load it:

This regex tester runs your pattern against sample text and highlights every match instantly. A table lists each match with its position, numbered capture groups and named groups, and a replace box shows the result of String.replace with references like $1 and $<name>, so you can perfect a find-and-replace before using it in code.

It uses the JavaScript (ECMAScript) regex engine built into your browser, the same one used by Node.js, TypeScript and most front-end code. Flags g, i, m, s, u and y can be toggled with checkboxes. Your pattern and test text stay on your computer, which makes it safe for log lines and real data.

How to use the Regex Tester tool

  1. Type your pattern between the slashes, without the surrounding / /.
  2. Tick the flags you need, for example g to find all matches or i to ignore case.
  3. Paste the text to test. Matches are highlighted and counted live.
  4. Check the table for capture group values.
  5. Optionally enter a replacement to preview the replaced text, then copy it.

Why use ToolOrca Regex Tester

  • Live highlighting of all matches
  • Numbered and named capture groups
  • Replace preview with $1 and $
  • All JavaScript flags: g i m s u y
  • Cheat sheet and ready-made patterns
  • Clear error messages for invalid patterns

Regex basics in one minute

A regular expression describes a text pattern. Ordinary characters match themselves, while special tokens match groups of characters: \d matches a digit, \w a word character, \s whitespace and . any character. Quantifiers say how many: + one or more, * zero or more, ? optional and {2,5} a range.

Parentheses create capture groups that you can reuse in a replacement, and ^ and $ anchor the match to the start and end of the text, or of each line with the m flag.

Avoiding slow patterns

Nested quantifiers such as (a+)+ can cause “catastrophic backtracking”, where a failed match takes exponential time. Prefer specific character classes ([^"]* instead of .*) and anchors. If the tester becomes slow on a pattern, that pattern will be slow in production too.

Frequently asked questions

Which regex flavor does this tester use?

JavaScript (ECMAScript), as implemented by your browser. Most syntax is shared with PCRE, Python and Java, but some features such as possessive quantifiers or conditionals are not available in JavaScript.

Why does my regex only find the first match?

Without the g (global) flag, JavaScript stops after the first match. Tick the g checkbox to find all of them.

How do I match a literal dot or bracket?

Escape it with a backslash: \., \(, \[. Inside a character class most characters are literal, so [.] also matches a dot.

What does the s flag do?

The s (dotAll) flag lets . match line breaks too. Without it, . stops at the end of each line.

Is there a regex for validating email addresses?

Simple patterns like the one in the presets catch typos, but no regex fully follows the email standard. The only reliable check is sending a confirmation email.