Regex Tester

Test regular expressions against sample text and see matches highlighted live in your browser. Build capture groups, compare greedy versus lazy quantifiers, or validate an email or URL slug pattern before shipping it, with no data sent to a server.

Related tools
Flags

Usage examples

Validating an email address format

Enter a regex that checks email format and put several strings in the test string to see at a glance which ones match and which don't.

Building a regex to pull a pattern out of log lines

Paste real log text and adjust your regex to see in real time whether it correctly picks out dates, IPs, or error codes.

Extracting just part of a match with capture groups

Use parentheses to create capture groups and confirm that only the part you want — like the year, month, and day of a date — is being pulled out.

Testing a password strength pattern before shipping it

Try a lookahead-heavy pattern like one requiring a digit, an uppercase letter, and a minimum length against several sample passwords to confirm it accepts and rejects the right ones before you put it in a signup form.

Checking whether a URL slug matches your routing rules

Test a pattern like ^[a-z0-9]+(?:-[a-z0-9]+)*$ against candidate slugs to make sure it accepts hyphenated lowercase paths and rejects spaces, uppercase letters, or double hyphens.

Comparing greedy and lazy quantifiers side by side

Run the same text through <.*> and <.*?> to see exactly how a greedy quantifier spans to the last possible closing tag while a lazy one stops at the first, which is a common source of surprising matches.

Naming capture groups for clearer extraction logic

Rewrite a pattern using (?<year>\d{4})-(?<month>\d{2})-(?<day>\d{2}) instead of plain parentheses to see each captured value labeled by name rather than by position, which is closer to how you'd read it back in code.

Quick reference

Regex flags: same pattern and input, flag off vs on

FlagsTest stringFlag offFlag on
g (Global)a1 b22 c333/\d+/ → "1"/\d+/g → "1", "22", "333"
i (Case-insensitive)Cat cat CAT/cat/g → "cat"/cat/gi → "Cat", "cat", "CAT"
m (Multiline)one\ntwo\nthree/^\w+/g → "one"/^\w+/gm → "one", "two", "three"
m (Multiline)a1\nb2\nc3/\d$/g → "3"/\d$/gm → "1", "2", "3"
s (Dot matches newline)a\nc abc/a.c/g → "abc"/a.c/gs → "a\nc", "abc"
u (Unicode)😀/^.$/ → No matches found./^.$/u → "😀"
u (Unicode)😀/\u{1F600}/ → No matches found./\u{1F600}/u → "😀"
u (Unicode)héllo/\p{L}+/ → No matches found./\p{L}+/u → "héllo"

Frequently asked questions

Is my text sent to a server?

No. All matching happens entirely in your browser, and the pattern and text you enter are never sent to a server.

What regex syntax does this use?

It uses your browser's JavaScript (ECMAScript) regex syntax directly. Syntax can differ slightly from other languages like Python or PCRE.

What happens if I turn off the "g" flag?

Without the "g" (global) flag, it finds only the first match, just like calling .exec() once in real code.

What happens if my pattern is invalid?

If the pattern itself isn't valid — unbalanced parentheses, for example — the exact error message JavaScript reports is shown.

What does each flag actually do?

"g" (global) finds every match instead of just the first. "i" ignores case. "m" makes ^ and $ match the start and end of each line instead of just the whole string. "s" lets . also match newline characters, which it otherwise doesn't. "u" enables full Unicode handling, including correct matching of characters outside the basic multilingual plane and stricter escape-sequence validation.

Does this support named capture groups and lookbehind?

Yes. Since it runs on your browser's native JavaScript engine, modern ECMAScript features like named groups (?<name>...) and both lookahead (?=...) / (?!...) and lookbehind (?<=...) / (?<!...) work as long as your browser is reasonably up to date — lookbehind support landed later than lookahead in some engines, so very old browsers may not support it.

What's the difference between greedy and lazy quantifiers?

A greedy quantifier like * or + tries to match as much text as possible and only backs off if needed, while adding a ? after it (*? or +?) makes it lazy, matching as little as possible. This matters most with wildcards like .* in text that contains repeated delimiters, such as HTML tags.

Why does my pattern match something I didn't expect?

The most common cause is an unescaped special character (like . or ( ) being treated as a metacharacter instead of a literal one, or a greedy quantifier matching further than intended. Pasting your exact test string here and watching the highlighted matches update live is usually the fastest way to spot the mismatch.

Is JavaScript regex syntax the same as Python's re or PCRE?

Mostly similar, but not identical. For example, Python uses (?P<name>...) for named groups while JavaScript uses (?<name>...), and some PCRE-only features like atomic groups or possessive quantifiers aren't available in JavaScript at all. If you're porting a pattern from another language, double-check it here before using it in a browser or Node.js context.