Match information
CopyType a replacement. Use $1, $2 for capture groups, $<name> for named groups, and $& for the whole match. Add the g flag to replace every match.
Write, test and debug regular expressions in real time, with live highlighting.
Type a replacement. Use $1, $2 for capture groups, $<name> for named groups, and $& for the whole match. Add the g flag to replace every match.
A regex tester lets you write a regular expression and instantly see what it matches in a block of text, without running any code. Type a pattern, paste your test string, and every match lights up as you go — with a full breakdown of the capture groups underneath. It turns the usual trial-and-error of "does this pattern actually work?" into something you can watch happen live.
This one runs on the JavaScript regex engine, right in your browser, so nothing you type is ever sent anywhere. You get all six flags as one-click toggles, a match inspector that shows positions and both numbered and named groups, a substitution panel for testing find-and-replace, and a library of ready-made patterns for the things people match most. It's built for everyone from someone learning their first character class to a developer debugging a gnarly lookahead.
g, i, m, s, u, y) to change how it matches.$1 or $<name> to insert captured text.Regular expressions show up everywhere text needs to be searched, validated, or reshaped:
Need to tidy your text first? Try the Text Cleaner or Find and Replace Text tool, or browse all our free developer tools.
A quick reference for the tokens you'll reach for most often:
| Token | What it matches |
|---|---|
. | Any single character except a newline. |
\d / \D | Any digit / any non-digit. |
\w / \W | Any word character (letter, digit, underscore) / its opposite. |
\s / \S | Any whitespace / any non-whitespace. |
[abc] / [^abc] | Any one of a, b, c / any character except those. |
^ / $ | Start / end of the string (or line, with the m flag). |
* + ? | Zero or more, one or more, or zero or one of the previous token. |
{2,5} | Between 2 and 5 of the previous token. |
(abc) | A capturing group you can reference or extract. |
(?:abc) | A non-capturing group (groups without capturing). |
(?<name>abc) | A named capturing group. |
a|b | Matches a or b (alternation). |
\b | A word boundary. |
(?=...) / (?!...) | Positive / negative lookahead. |
A regular expression, or regex, is a compact pattern that describes a set of strings. Instead of searching for one fixed word, you describe a shape — "three digits, a dash, then four digits" — and the engine finds every piece of text that fits. It's a standard tool in almost every programming language for searching, validating, and transforming text.
They change how the pattern is applied. g (global) finds every match instead of just the first; i makes it case-insensitive; m (multiline) lets ^ and $ match at each line break; s (dotall) lets . match newlines too; u turns on full Unicode handling; and y (sticky) only matches starting exactly where the last match ended.
Parentheses around part of a pattern create a capture group, which remembers the text it matched so you can pull it out or reuse it. This tool lists every group under each match. Use (?:...) when you want to group tokens without capturing, and (?<name>...) to give a group a readable name.
Turn on Substitution and type a replacement string. You can insert captured text with $1, $2, and so on, use $<name> for named groups, or $& for the entire match. Remember to add the g flag if you want every match replaced rather than just the first.
By default quantifiers are greedy: .* grabs as much as it can. Adding a ? makes them lazy, so .*? grabs as little as possible. Lazy quantifiers are handy when you want the shortest match, like the text between the nearest pair of quotes or tags.
Two different flags control line behavior. The m flag makes ^ and $ match at the start and end of each line, while the s flag makes . match newline characters. If your pattern should span line breaks, you usually want the s flag.
A reliable email pattern is \b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b, and a simple URL pattern is https?://[^\s]+. Both are in the sample dropdown so you can load them and tweak them against your own text.
It uses the JavaScript (ECMAScript) regex engine, the same one that runs in every web browser and in Node.js. Most syntax is shared across languages, but a few features differ from PCRE, Python, or Java — lookbehind, for instance, is supported in modern browsers but written slightly differently in other flavors.
Completely. The tester runs entirely in your browser with JavaScript, so your patterns and test strings are never uploaded, stored, or logged. You can safely test against sensitive data, and the tool keeps working offline once the page has loaded.