Enter a pattern and test string to see results

Quick Patterns

Phone Email URL Hex Color

What is Regex Tester?

A Regex Tester is a free online tool that lets you test and debug regular expressions in real-time against custom input text. Regular expressions are one of the most powerful tools for text processing — used for validation, search, extraction, and replacement — but they are also notoriously difficult to get right the first time. A single misplaced character, missing escape, or incorrect quantifier can cause your regex to match nothing, match everything, or worse, introduce security vulnerabilities like ReDoS (Regular Expression Denial of Service).

Our Regex Tester provides an interactive sandbox where you can enter any regex pattern, toggle flags, and immediately see which parts of your test string match. This instant feedback loop makes it easy to debug patterns, understand how regex works, and verify that your expression behaves correctly across different inputs before deploying it to production code.

Understanding Regex Flags

Flags modify how a regular expression is evaluated. Our tester supports the three most commonly used flags:

FlagNameEffectExample
gGlobalFinds all matches instead of stopping after the first one/a/g in "banana" finds 3 matches
iCase InsensitiveIgnores uppercase/lowercase differences/hello/i matches "Hello", "HELLO", "hello"
mMultilineMakes ^ and $ match line boundaries, not just string boundariesUseful for validating each line in multi-line input

How to Use Regex Tester

  1. Enter Pattern — Type or paste your regular expression in the pattern input field
  2. Toggle Flags — Check or uncheck the g (global), i (case insensitive), and m (multiline) flags as needed
  3. Enter Test String — Type or paste the text you want to test the pattern against
  4. View Results — See instant feedback showing match count, matched values, and errors if the pattern is invalid
  5. Iterate — Refine your pattern based on the results and test again

Key Features

  • Real-Time Testing — Results update instantly as you type the pattern or modify the test string
  • Match Count — Displays the total number of matches found in the test string
  • Detailed Match List — Shows each match individually with its position number, making it easy to verify specific captures
  • Error Detection — Immediately highlights invalid regex patterns with descriptive error messages (e.g., "Unterminated group", "Invalid escape")
  • Quick Pattern Library — One-click buttons to load common patterns for phone numbers, emails, URLs, and hex colors
  • Flag Toggles — Easy checkboxes to enable global, case-insensitive, and multiline flags

Common Regex Patterns Reference

PatternMatchesExample Input
\d{3}-\d{3}-\d{4}US phone numbers555-123-4567
[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Email addressesuser@example.com
https?://[^\s]+HTTP and HTTPS URLshttps://example.com/page
#[a-fA-F0-9]{6}6-digit hex colors#FF5733
\b(?:\d{1,3}\.){3}\d{1,3}\bIP addresses (basic)192.168.1.1
^[a-zA-Z0-9]+$Alphanumeric onlyUsername123
\b[A-Z][a-z]+\bCapitalized wordsHello World
\d{4}-\d{2}-\d{2}Dates (YYYY-MM-DD)2026-06-18

Use Cases for Regex Testing

  • Form Validation — Test and debug input validation patterns before adding them to web forms
  • Data Extraction — Verify that your extraction pattern correctly identifies all target data in sample text
  • Log Analysis — Develop and test patterns for parsing server logs, error logs, and application traces
  • Code Refactoring — Test search patterns before performing find-and-replace operations across large codebases
  • Web Scraping — Validate regex patterns for extracting data from HTML content during scraper development
  • Learning Regex — Experiment with regex syntax and see how different patterns behave with various inputs
  • Security Auditing — Test patterns for input sanitization and SQL injection prevention

Tips for Debugging Regular Expressions

  • Start with the simplest pattern that can match your target, then add complexity gradually
  • Test edge cases — empty strings, very long inputs, strings with special characters, strings with only partial matches
  • Use anchors^ at the start and $ at the end when you want to match the entire string
  • Watch out for greedy matching — Use *?, +?, or ?? for lazy matching when appropriate
  • Escape special characters — Characters like ., *, +, ?, (, ), [, ], {, }, ^, $, |, and \ need to be escaped with \ when you want to match them literally
  • Use character classes instead of alternation when possible — [aeiou] is more efficient than (a|e|i|o|u)

Frequently Asked Questions

What does the global flag (g) do?

The global flag tells the regex engine to find all matches in the input string, not just the first one. Without the g flag, /a/ in "banana" returns only the first "a". With /a/g, it returns all three "a" characters.

Why does my regex show "Invalid regex"?

This usually means the pattern contains a syntax error — an unclosed group, an invalid escape sequence, a misplaced quantifier, or unbalanced brackets. The error message will indicate the specific issue. Common causes include using / without escaping, missing closing parentheses, or using unsupported character classes.

Can I test regex for multiple lines?

Yes! Enable the Multiline (m) flag to make ^ and $ match the start and end of each line instead of the start and end of the entire string. This is essential for validating patterns like email addresses in a comma-separated list or headers in structured text files.

What is the difference between \d and [0-9]?

In most regex engines, \d matches any digit character including Unicode digits (e.g., Arabic-Indic digits), while [0-9] matches only the ASCII digits 0 through 9. For most practical purposes, they are interchangeable, but [0-9] is more predictable when working with English-language text.

How do I match a literal dot (.)?

Use \. to match a literal period character. Without the backslash, . is a special character that matches any single character (except newline). This is one of the most common regex mistakes — forgetting to escape the dot.

Can I use lookahead and lookbehind in this tester?

Yes, the tester supports JavaScript regex syntax, which includes lookahead ((?=...) for positive, (?!...) for negative) and lookbehind ((?<=...) for positive, (?<!...) for negative). However, note that lookbehind may have browser compatibility limitations in older environments.