Skip to main content

Regex Tester

Test and debug regular expressions in real time. Highlights matches, shows capture groups, explains your pattern, and runs entirely in your browser.

How to use

Enter your regular expression in the Regular Expression field. Toggle the g, i, m, and s flags to control matching behavior. Type or paste text into the Test String area to see matches highlighted in real time.

Use the tabs below to explore Capture Groups, test a Substitution pattern, read an Explanation of your regex, browse the Cheat Sheet, or recall recent patterns from History.

What is a regular expression?

A regular expression (regex) is a small pattern language for finding text: "a word that starts with a capital letter", "a date like 2026-12-04", "everything between quotes". Regexes are built into almost every programming language, into editors like VS Code, and into tools like grep, so they are worth learning once and testing carefully, because a pattern that looks right can easily match too much or too little.

How it works

Type a pattern and some test text and every match is highlighted as you type. The tester uses your browser's JavaScript (ECMAScript) regex engine, the same one used by Node.js and front-end code. Flags change how the pattern is applied:

  • g (global): find all matches, not only the first
  • i (ignore case): a also matches A
  • m (multiline): ^ and $ match at the start and end of each line
  • s (dotAll): . also matches line breaks

The tabs show each match's capture groups, let you try a substitution (with $1, $2 or $<name> references), explain the pattern piece by piece, offer a cheat sheet, and keep a history of recent patterns in your browser. Nothing is sent to a server.

Examples

Pattern Matches
\d+ runs of digits: 42, 2026
^\s*$ empty or whitespace-only lines (with m)
\b[A-Z][a-z]+\b capitalised words
(\d{4})-(\d{2})-(\d{2}) ISO dates, with year, month and day as groups 1–3
[\w.+-]+@[\w-]+\.[\w.]+ a simple e-mail address check
"([^"]*)" text inside double quotes, captured without the quotes

With the date pattern above and the replacement $3/$2/$1, 2026-12-04 becomes 04/12/2026.

Limitations

  • Results follow JavaScript regex rules. Other engines differ: PCRE (PHP), Python's re, Java and .NET support some syntax JavaScript does not (possessive quantifiers, \A and \Z, inline modifiers like (?i)), and the other way round.
  • Flags u (Unicode) and y (sticky) are not offered as toggles.
  • A badly written pattern on long text, such as (a+)+$, can take a very long time to fail (catastrophic backtracking) and make the page slow.

Frequently asked questions

Which regex flavor does this tester use?

The JavaScript (ECMAScript) engine built into your browser. Patterns that work here work the same way in browser JavaScript, Node.js and TypeScript. Most simple patterns also work in PHP, Python and Java, but advanced syntax can differ.

Why does my regex only find the first match?

Turn on the g (global) flag. Without it, a JavaScript regex stops after the first match.

How do I match across several lines?

Use the s flag so that . also matches line breaks, and the m flag if you want ^ and $ to match at the start and end of every line instead of the whole text.

How do capture groups work?

Parentheses capture the part of the match inside them: in (\d{4})-(\d{2}), group 1 is the year and group 2 the month. Name them with (?<year>\d{4}) and refer to them as $<year> in a replacement. Use (?:…) to group without capturing.

How do I match a literal dot, bracket or question mark?

Escape it with a backslash: \., \[, \(, \?, \*, \+. Inside a character class like [.], most special characters are literal already.

Is my test text saved or uploaded?

No. Matching runs in your browser. The history tab stores recent patterns only in your own browser's local storage, and you can clear it at any time.