Regex Tester

/ /

Match Results

0 matches

Enter a pattern to see matches

Highlighted Matches

How to Use the Regex Tester

Step 1: Enter Your Pattern

Type your regular expression in the pattern field. Use the checkboxes below to toggle flags like global matching or case-insensitivity.

Step 2: Add Test Text

Paste or type the text you want to test against. The tool shows matches in real-time as you type.

Step 3: Review Matches

See all matches highlighted in the output, with capturing groups displayed separately for detailed analysis.

Common Regex Patterns

Click any pattern to use it in the tester above.

Validation Patterns

Email AddressValidates email format
URLValidates HTTP/HTTPS URLs
Phone Number (E.164)International phone format
Strong PasswordMin 8 chars, letters + numbers

Extraction Patterns

IPv4 AddressMatches IP addresses
Hex Color CodeMatches #RGB and #RRGGBB
Date (YYYY-MM-DD)ISO date format
Currency (USD)Matches $100 or $99.99

Text Processing

WhitespaceMatches all whitespace
HTML TagsMatches HTML/XML tags
WordsMatches individual words
LinesMatches complete lines

Regex Quick Reference

Character Classes

.Any character except newline
\dDigit (0-9)
\DNon-digit
\wWord character (a-z, A-Z, 0-9, _)
\WNon-word character
\sWhitespace
\SNon-whitespace

Quantifiers

*0 or more
+1 or more
?0 or 1
{n}Exactly n
{n,}n or more
{n,m}Between n and m

Anchors & Groups

^Start of string/line
$End of string/line
\bWord boundary
()Capturing group
(?:)Non-capturing group
|Alternation (OR)

Frequently Asked Questions

What is a regular expression (regex)?

A regular expression is a sequence of characters that defines a search pattern. It's used for pattern matching within strings, such as validating email addresses, extracting data, or performing search-and-replace operations in text.

What do the regex flags mean?

Flags modify how the regex engine works. 'g' (global) finds all matches, 'i' makes matching case-insensitive, 'm' (multiline) makes ^ and $ match line starts/ends, and 's' (dotall) makes the dot match newline characters.

Why isn't my regex matching anything?

Common issues include forgetting to escape special characters (like . or $), using the wrong anchors (^ and $), or having the wrong flags enabled. Try simplifying your pattern and building it up piece by piece.

Is this regex tester compatible with JavaScript?

Yes! This tool uses JavaScript's native RegExp engine, so patterns you create here will work directly in JavaScript code. The syntax is also compatible with most modern regex implementations.

Horizontal Banner (Responsive) 728x90 / 320x100

How to Use This Tool

  1. Enter Your Pattern: Type your regular expression in the pattern field between the forward slashes. Escape special characters with backslashes (e.g., \. to match a literal period, \\ to match a backslash).
  2. Configure Flags: Enable "g" (global) to find all matches rather than stopping at the first. Use "i" for case-insensitive matching, "m" for multiline mode where ^ and $ match line boundaries, and "s" to make the dot match newlines.
  3. Paste Test Text: Enter the string you want to match against in the test string textarea. The tool highlights matches in real-time as you type, showing captured groups separately.
  4. Analyze Results: Review the match count, highlighted matches, and capturing group contents. Click any common pattern from the examples to load it instantly and see how it works.

Technical Details

This tool uses JavaScript's native RegExp engine, which implements a subset of Perl-compatible regular expressions (PCRE). Key supported features include character classes (\d, \w, \s), quantifiers (*, +, ?, {n,m}), anchors (^, $, \b), capturing and non-capturing groups, alternation (|), and lookahead assertions ((?=...) and (?!...)). JavaScript does not support lookbehind assertions in all browsers, possessive quantifiers, or atomic groups.

The regex engine uses backtracking for quantifier matching, which can cause catastrophic performance on patterns with nested quantifiers matching overlapping content (e.g., (a+)+ against a long string of "a"s). For user-supplied patterns in production systems, implement execution timeouts. Unicode support requires the "u" flag for proper handling of surrogate pairs and Unicode property escapes (\p{...}).

Common Mistakes to Avoid

  • Forgetting to Escape Special Characters: Characters like . * + ? ^ $ { } [ ] \ | ( ) have special meaning. To match them literally, escape with a backslash: \. matches a period, \$ matches a dollar sign.
  • Greedy vs. Lazy Quantifiers: By default, .* is greedy and matches as much as possible. For HTML tag matching, <.*> matches from the first < to the last >. Use <.*?> (lazy) to match individual tags.
  • Anchor Misunderstanding: Without the "m" flag, ^ and $ match only the start and end of the entire string, not line boundaries. Enable multiline mode for line-by-line matching in multi-line text.

Related Tools

Need pre-built patterns? Browse our Regex Pattern Library for tested expressions for emails, URLs, and more. For understanding complex patterns, the Regex Explainer provides plain-English breakdowns.

Frequently Asked Questions

What is a regular expression (regex)?

A regular expression is a sequence of characters that defines a search pattern. It's used for pattern matching within strings, such as validating email addresses, extracting data, or performing search-and-replace operations in text.

What do the regex flags mean?

Flags modify how the regex engine works. 'g' (global) finds all matches, 'i' makes matching case-insensitive, 'm' (multiline) makes ^ and $ match line starts/ends, and 's' (dotall) makes the dot match newline characters.

Why isn't my regex matching anything?

Common issues include forgetting to escape special characters (like . or $), using the wrong anchors (^ and $), or having the wrong flags enabled. Try simplifying your pattern and building it up piece by piece.

Is this regex tester compatible with JavaScript?

Yes! This tool uses JavaScript's native RegExp engine, so patterns you create here will work directly in JavaScript code. The syntax is also compatible with most modern regex implementations.