Free Online Regex Tester

Test regular expression patterns with live matching and highlighting

This free online regex tester lets you write a regular expression and test it against sample text in real time. Matches are highlighted instantly as you type. Toggle flags, load common pattern presets, and copy results with one click. All processing happens in your browser — nothing is sent to a server.

Test Your Regex Pattern

/ /
gglobal icase-insensitive mmultiline sdotAll
Quick Presets
Live Results 0 matches
Enter a pattern and test text to see highlighted matches...

About Regular Expressions

Regular expressions (regex or regexp) are patterns that describe sets of strings. They are used across programming languages and command-line tools for searching, validating, and transforming text. Common tasks include input validation (email, phone, ZIP code), log parsing, data extraction from HTML or CSV, and search-and-replace operations.

This tool uses the JavaScript regex engine built into your browser. It supports standard features: character classes (\d, \w, \s), quantifiers (*, +, ?, {n,m}), anchors (^, $, \b), alternation (|), groups and back-references, lookahead, and lookbehind (in modern browsers). It does not support PCRE-only features like recursive patterns or possessive quantifiers.

Learn more: See the regex cheatsheet for a quick syntax reference.

Worked Examples

1. Extract email addresses

Pattern\b[\w.-]+@[\w.-]+\.\w+\b
Flagsgi
InputContact [email protected] or [email protected] for details.
Matches[email protected], [email protected]

2. Find US phone numbers

Pattern\d{3}[-.\s]?\d{3}[-.\s]?\d{4}
Flagsg
InputCall 555-123-4567 or 800.555.0199 for support.
Matches555-123-4567, 800.555.0199

3. Validate a hex color code

Pattern#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})\b
Flagsgi
InputUse #FF5733 for the heading and #0af for links.
Matches#FF5733, #0af

Regex Flag Reference

Flag Name Effect
gGlobalFind all matches, not just the first
iCase-insensitiveTreat uppercase and lowercase as the same
mMultiline^ and $ match start/end of each line
sDotAll. matches newline characters too
uUnicodeEnable Unicode matching for \p{} property escapes
yStickyMatch only at the index indicated by lastIndex

Frequently Asked Questions

What is a regex tester?

A regex tester is a tool that lets you write a regular expression pattern and test it against sample text in real time. It highlights matches, shows capture groups, and reports errors instantly so you can build and debug patterns without running code.

What regex syntax does this tool use?

This tool uses the JavaScript regular expression engine built into your browser. It supports standard syntax including character classes, quantifiers, lookahead, lookbehind (in modern browsers), named groups, and Unicode escapes. It does not support PCRE-only features like recursive patterns.

What do the g, i, m, and s flags mean?

g (global) finds all matches instead of stopping at the first. i (case-insensitive) ignores letter case. m (multiline) makes ^ and $ match the start and end of each line, not just the whole string. s (dotAll) makes the dot (.) match newline characters as well.

How do I match an email address with regex?

A common pattern is \b[\w.-]+@[\w.-]+\.\w+\b with the gi flags. This matches strings like [email protected]. For strict RFC 5322 compliance you need a much longer pattern, but this covers most practical cases.

How do I escape special characters in regex?

Place a backslash before any special character to match it literally. The special characters are . * + ? ^ $ { } [ ] ( ) | \. For example, to match a literal dot, use \. instead of just a dot.

What is the difference between .* and .*? in regex?

.* is greedy and matches as many characters as possible. .*? is lazy (non-greedy) and matches as few characters as possible. For example, given the text <b>one</b><b>two</b>, the pattern <b>.*</b> matches the entire string, while <b>.*?</b> matches <b>one</b> and <b>two</b> separately.

What is a capture group in regex?

A capture group is a section of a pattern enclosed in parentheses. It isolates part of the match for extraction or back-referencing. For example, in the pattern (\d{3})-(\d{4}), group 1 captures the first three digits and group 2 captures the last four.

How do I test a regex pattern for a phone number?

For US phone numbers, use \d{3}[-.\s]?\d{3}[-.\s]?\d{4} with the g flag. This matches formats like 555-123-4567, 555.123.4567, 555 123 4567, and 5551234567. Click the Phone preset in the tool to load it automatically.

Can I use this regex tester on my phone?

Yes. The tool is fully responsive and works on any device with a modern browser, including phones and tablets. No app install is required.

Is my data sent to a server when I use this tool?

No. All pattern matching runs in your browser using JavaScript. Your text and patterns are never transmitted to any server. Nothing is stored after you close or refresh the page.

Privacy and Limitations

All regex matching runs locally in your browser using the JavaScript engine. Your text and patterns are never sent to a server, and nothing is stored or logged. When you close or refresh the page, all input is cleared.

This tool uses JavaScript regex syntax. Some features available in other engines (PCRE, .NET, Python re) may not be supported. Lookbehind assertions require a modern browser (Chrome 62+, Firefox 78+, Safari 16.4+). Performance may degrade on very large inputs (100,000+ characters) or with patterns that cause catastrophic backtracking.

Related Tools

Related Tools

View all tools
Copied!
Request a New Tool
Improve This Tool