Skip to main content

Regex Tester

Free online regular expression tester with real-time matching

Free online regex tester to test and debug regular expressions in real-time. Enter your pattern and test text, see all matches highlighted instantly with capture groups. Supports flags like g, i, m, s, u. All processing happens in your browser.

//
Matches found: 0

Enter a pattern and test text to see matches


How to test regular expressions?

Testing and debugging regular expressions is easy with our real-time regex tester. Here's how to use it:

  • Type or paste your regular expression pattern into the 'Pattern' field (without delimiters). For example: \d{3}-\d{4} to match phone number formats like 123-4567.
  • Select any flags you need: g (global - match all), i (case-insensitive), m (multiline), s (dotall - . matches newlines), or u (unicode).
  • Enter your test text in the main text area. Matches are highlighted in real-time with distinct colors for each match.
  • View detailed match information below: the total number of matches, each match's value and position, and any captured groups within each match.

When would you use a regex tester?

Regular expressions are powerful but can be tricky to get right. A regex tester is essential whenever you're working with pattern matching:

  • Form validation: Test email, phone, URL, or ZIP code patterns before adding them to your code.
  • Data extraction: Build and refine patterns to extract specific information from text, like dates, prices, or IDs.
  • Log analysis: Develop regex patterns to parse server logs, error messages, or structured data files.
  • Search and replace: Test find-and-replace patterns before running them on important documents.
  • Learning and teaching: Experiment with regex syntax to understand how patterns work and what they match.

Related Tools

You May Also Need

Understanding regular expression basics

Regular expressions (regex) are patterns used to match character combinations in strings. They're incredibly powerful for text processing, validation, and extraction. Common elements include: literal characters (match themselves), metacharacters like . (any character), * (zero or more), + (one or more), ? (optional), \d (digit), \w (word character), \s (whitespace), anchors like ^ (start) and $ (end), character classes like [a-z], and groups with (). Understanding these building blocks lets you create patterns for virtually any text-matching task.

Regex flags explained

  • g (global): Find all matches rather than stopping after the first match. Essential for finding every occurrence in your text.
  • i (case-insensitive): Makes the pattern case-insensitive so [a-z] matches both 'a' and 'A'. Great for searching without worrying about capitalization.
  • m (multiline): Changes the behavior of ^ and $ to match the start/end of each line, not just the start/end of the entire string. Useful for parsing line-oriented data.
  • s (dotall): Makes the dot (.) match newline characters as well. Without this flag, . matches everything except newlines.
  • u (unicode): Enables full Unicode matching, allowing \w, \d, and other shorthands to work with Unicode characters beyond ASCII.

Frequently Asked Questions (FAQs)

How does the regex tester work?

The regex tester runs entirely in your browser using JavaScript's built-in RegExp engine. As you type your pattern and test text, it re-evaluates the regex in real-time, highlighting all matches in your input text with different colors. Each match is also displayed below with its position (start and end index) and any captured groups. Nothing is sent to any server - your data stays private on your device.

What regex syntax is supported?

This tester uses JavaScript's RegExp syntax, which supports most standard regex features including: literal characters, metacharacters (., *, +, ?, |, ^, $), character classes ([a-z], [^abc], \d, \w, \s), quantifiers ({3}, {2,5}), groups and backreferences ((abc), \1), lookahead/lookbehind ((?=), (?!), (?<=), (?<!)), and flags (g, i, m, s, u). Some advanced PCRE features like atomic groups and recursion are not supported in JavaScript.

Why are my matches not showing up?

If no matches are found, check your pattern carefully: make sure you haven't missed a closing bracket, parenthesis, or backslash. Verify your flags - for example, forgetting the 'i' flag when your pattern uses uppercase but your text is lowercase. Also check if you need the 'm' flag when using ^ or $ anchors on multi-line text. Try simplifying your pattern to isolate the issue.

What does each colored highlight mean?

Each match is highlighted with a unique color to help you distinguish between multiple matches visually. When you click on a match in the result list below, the corresponding highlight in the text will be scrolled into view, making it easy to locate specific matches in long text.

Can I use captured groups for replacement?

This tool focuses on matching and visualization, but the captured group information shown below each match is exactly what you'd use in a replacement pattern. In JavaScript, captured groups are referenced as $1, $2, etc. in replacement strings. Use this tester to verify your groups are capturing the right content before applying them in your actual code.

Is my text sent to any server?

No, absolutely not. Everything happens entirely in your browser. Your regex pattern and test text never leave your device. This means you can safely test patterns against sensitive data like passwords, API keys, or personal information without any privacy concerns. As soon as you refresh or leave the page, everything is gone.

What's the difference between greedy and lazy matching?

Greedy quantifiers (*, +) match as much as possible, while lazy quantifiers (*?, +?) match as little as possible. For example, on the text '&lt;div&gt;Hello&lt;/div&gt;', the pattern &lt;.*&gt; would match the entire string (greedy), while &lt;.*?&gt; would match '&lt;div&gt;' only (lazy). Use lazy quantifiers when you want the shortest possible match that still satisfies the pattern.

Recently Used Tools