Regex Tester & Debugger

Test & debug regular expressions online

//
Flags:
Test String

Free Online Regex Tester & Debugger - 100% Client-Side

Test, debug, and validate regular expressions online with real-time match highlighting, capture group visualization, and find & replace preview. Our regex tester runs 100% in your browser—no server uploads, complete privacy. Perfect for developers debugging regex patterns, testing string matching, and learning regular expressions with interactive feedback.

Real-Time Testing

See matches update instantly as you type. Visual highlighting shows exactly what your regex captures with color-coded groups.

100% Private

All testing happens locally in your browser. Your regex patterns and test strings never leave your device.

Code Export

Copy working regex code for JavaScript, Python, Go, or Java with one click. Ready to paste into your project.

Key Features

Visual Match Highlighting

See exactly what your regex matches with color-coded highlighting. Unlike regex101 which shows matches in a separate panel, we highlight matches directly in your test string for instant visual feedback.

  • Color-coded match highlighting in test string
  • Match table showing all matches with positions
  • Capture group extraction with group numbers
  • Named capture group support

Find & Replace Mode

Test find & replace operations with live preview. Use capture group references ($1, $2) in replacement text and see results instantly before applying changes to your code.

  • Live replacement preview as you type
  • Capture group references ($1, $2, $3...)
  • Named group references ($<name>)
  • Copy result with one click

Test Case Management

Save test cases to validate your regex against multiple strings. Mark each test as "should match" or "should not match" and run all tests at once to verify your pattern works correctly across all scenarios.

  • Add unlimited test cases
  • Pass/fail indicators for each test
  • Run all tests with one click
  • Perfect for TDD regex development

Built-in Cheatsheet

Quick reference sidebar with all regex tokens, quantifiers, anchors, and special characters. No need to Google regex syntax—everything you need is right there in the tool.

  • Character classes (\\w, \\d, \\s)
  • Quantifiers (*, +, ?, {n,m})
  • Anchors (^, $, \\b)
  • Lookaround assertions
  • Groups and alternation

How to Use the Regex Tester

1. Enter Your Regex Pattern

Type your regular expression in the pattern field. The pattern is automatically wrapped in forward slashes (/ /) like in JavaScript. Select flags:

  • g (Global) - Find all matches, not just the first
  • i (Ignore Case) - Case-insensitive matching
  • m (Multiline) - ^ and $ match line boundaries
  • s (Dot All) - . matches newlines
  • u (Unicode) - Full unicode support
  • y (Sticky) - Match from lastIndex position

2. Add Test String

Paste or type the text you want to test your regex against. Matches will be highlighted in real-time as you type. For multiline patterns, press Enter to add line breaks.

3. View Results

In Match mode, see highlighted matches in your test string and a detailed match table showing positions and capture groups. In Replace mode, enter replacement text (use $1, $2 for capture groups) and see the result instantly.

4. Export Code

Once your regex works, click an export button to copy code for JavaScript, Python, Go, or Java. The code includes your pattern, flags, and is ready to paste into your project.

Common Regex Patterns

Email Address

\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b

Matches most email formats. Add flags: i for case-insensitive.

URL/Website

https?://[^\s]+

Matches HTTP and HTTPS URLs. Use with g flag to find all URLs.

Phone Number (US)

\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}

Matches formats: (123) 456-7890, 123-456-7890, 123.456.7890

Date (YYYY-MM-DD)

\d{4}-\d{2}-\d{2}

Matches ISO 8601 date format: 2025-02-14

Hex Color

#[0-9A-Fa-f]{6}

Matches 6-digit hex colors: #FF5733, #1a2b3c

IP Address (IPv4)

\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b

Matches IPv4 addresses: 192.168.1.1

Frequently Asked Questions

What is a regular expression (regex)?

A regular expression (regex or regexp) is a sequence of characters that defines a search pattern, mainly for use in pattern matching with strings. Regex is used for text searching, validation (email, phone numbers), find & replace operations, and data extraction. It's supported in most programming languages including JavaScript, Python, Java, Go, PHP, and more.

What do the regex flags mean?

Flags modify how the regex pattern behaves. g (Global) finds all matches instead of stopping after the first. i (Ignore Case) makes matching case-insensitive. m (Multiline) makes ^ and $ match line boundaries instead of just string start/end. s (Dot All) makes . match newline characters.u (Unicode) enables full unicode support. y (Sticky) matches only from the lastIndex position.

How do I use capture groups in regex?

Capture groups are parts of your regex wrapped in parentheses that extract specific portions of matches. For example, in (\d{3})[-.](\d{3})[-.](\d{4})for phone numbers, the three groups capture area code, prefix, and line number separately. In replacements, reference groups with $1, $2, etc. Named groups use(?<name>pattern) and are referenced with $<name>.

What's the difference between greedy and lazy quantifiers?

Greedy quantifiers (*, +, {n,m}) match as much text as possible. For example, <.+> on "<a>link</a>" matches the entire string. Lazy quantifiers (*?, +?, {n,m}?) match as little as possible. <.+?> matches only "<a>" and "</a>" separately. Use lazy quantifiers when you want to match the shortest possible string.

How do I match special characters literally?

Special regex characters like . * + ? [ ] {} ( ) ^ $ | \\ have special meanings. To match them literally, escape them with a backslash. For example, to match a literal period, use\. instead of .To match "example.com" exactly, use example\.com. To match parentheses, use \( and \).

Why isn't my regex matching newlines?

By default, the dot (.) metacharacter doesn't match newline characters. To make . match newlines, enable the s (Dot All) flag. Alternatively, use [\s\S] or(.|\n) to explicitly match any character including newlines. For multiline matching where ^ and $ should match line boundaries (not just string start/end), enable the m (Multiline) flag.

Regex Best Practices

  • Start simple, iterate: Begin with a basic pattern and refine it as you test. Don't try to write perfect regex on the first try.
  • Use test cases: Create test cases for both matches and non-matches to ensure your regex is precise and doesn't have false positives.
  • Be specific: Use \\d instead of ., use \\s instead of .*, use character classes [a-z] instead of .+ when possible. Specific patterns are faster and more accurate.
  • Avoid catastrophic backtracking: Nested quantifiers like (a+)+ can cause exponential time complexity. Test your regex on large inputs to ensure good performance.
  • Use non-capturing groups: If you don't need to extract a group, use (?:pattern) instead of (pattern) for better performance.
  • Validate, don't parse: Regex is great for validation (email format, phone format) but not for parsing complex nested structures like HTML or JSON. Use proper parsers for those.