webby.tools

Regex Tester

Enter a regular expression and test string to instantly see all matches highlighted, capture group details, and a substitution preview. Everything runs in your browser — no data sent anywhere.

/ /

Use $1, $2, etc. to reference capture groups

Match Results

Highlighted Text

Match Details

Regular Expression Quick Reference

Regular expressions (regex) are a pattern-matching language used across virtually every programming language. The tester above uses JavaScript's regex engine, which follows PCRE-like syntax.

Character Classes

Pattern Matches
. Any character (except newline)
\d Any digit 0–9
\w Word character (letter, digit, underscore)
\s Whitespace (space, tab, newline)
[abc] Any of a, b, or c
[^abc] Any character except a, b, c
[a-z] Any lowercase letter a through z

Quantifiers

Pattern Meaning
* 0 or more times
+ 1 or more times
? 0 or 1 time (optional)
{n} Exactly n times
{n,m} Between n and m times

Anchors and Groups

Pattern Meaning
^ Start of string (or line with m flag)
$ End of string (or line with m flag)
\b Word boundary
(abc) Capture group — accessible as $1, $2, etc.
(?:abc) Non-capturing group
a|b a or b (alternation)

Common Pattern Examples

Pattern Matches
\b\d{3}[-.\s]?\d{3}[-.\s]?\d{4}\b US phone numbers
[\w.-]+@[\w.-]+\.[a-z]{2,} Email addresses
https?://[^\s]+ HTTP/HTTPS URLs
\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b IPv4 addresses

If you work with JSON, the JSON formatter can help you clean up and validate JSON before using regex on it. For text manipulation without regex, see the find and replace tool.

Frequently Asked Questions

What regex flavor does this tester use?

This tool uses JavaScript's built-in RegExp engine. It is largely compatible with PCRE (Perl-Compatible Regular Expressions) but with some differences: JavaScript does not support lookbehinds of variable length, named backreferences use a slightly different syntax ((?<name>)), and some advanced PCRE features like possessive quantifiers are not available.

Why is the global (g) flag checked by default?

Without the g flag, JavaScript's RegExp stops after the first match. Enabling g by default means you see all matches in your test string, which is what most users expect when testing a pattern.

What does the multiline (m) flag do exactly?

With m, the ^ anchor matches the start of each line (not just the start of the entire string), and $ matches the end of each line. This is essential when processing text with newlines where you want to match on a per-line basis.

How do I escape special regex characters?

To match a literal special character (like ., *, +, (, ), [, {, \), prefix it with a backslash: \. matches a literal period, \( matches a literal parenthesis, etc.

This website may contain affiliate links. If you click on an affiliate link and make a purchase, we may receive a small commission at no additional cost to you.