Regex Tester

Test regular expressions against text with match highlighting and group capture.

Privacy First

This tool runs entirely in your browser. No data is sent to any server. Your input remains completely private.

//g

Flags

Quick Reference

. Any character\d Digit (0-9)\w Word character\s Whitespace* 0 or more+ 1 or more? Optional^ Start / $ End

What are Regular Expressions?

Regular expressions (regex or regexp) are powerful patterns used to match, search, and manipulate text. They provide a concise and flexible way to identify strings of text—such as particular characters, words, or patterns of characters—based on pattern-matching rules.

Originally developed in the 1950s as a theoretical computer science concept, regular expressions have become an indispensable tool in programming, text processing, data validation, and countless other applications. Every major programming language supports regex, and understanding them is a fundamental skill for developers.

Why Use a Regex Tester?

Writing regular expressions can be challenging. A single misplaced character can completely change what a pattern matches. Our Regex Tester helps you:

Visualize Matches

See exactly what your pattern matches in real-time. Matched text is highlighted, making it immediately clear whether your regex is working as intended.

Debug Patterns

When a regex doesn't match what you expect, or matches too much, the visual feedback helps you understand what's happening and adjust your pattern.

Learn Safely

Experiment with regex syntax without worrying about breaking anything. Our tool provides clear error messages and includes safeguards against patterns that could cause problems.

Capture Groups

See the content captured by each group in your regex. This is essential when you need to extract specific parts of a match.

Understanding Regex Flags

Flags modify how a regular expression behaves. Our tester supports the following flags:

Global (g)

Without this flag, regex only finds the first match. With it, all matches in the text are found.

Case Insensitive (i)

Makes the pattern match regardless of letter case. "hello" would match "Hello", "HELLO", and "hElLo".

Multiline (m)

Changes how ^ and $ work. Normally they match the start and end of the entire string. With this flag, they match the start and end of each line.

Dotall (s)

Normally, the . (dot) matches any character except newlines. With this flag, it matches newlines too.

Unicode (u)

Enables full Unicode support, allowing patterns to correctly match characters outside the basic ASCII range.

Regex Syntax Quick Reference

Character Classes

  • . - Any character (except newline)
  • \d - Any digit (0-9)
  • \w - Any word character (a-z, A-Z, 0-9, _)
  • \s - Any whitespace character
  • [abc] - Any of a, b, or c
  • [^abc] - Any character except a, b, or c

Quantifiers

  • * - Zero or more
  • + - One or more
  • ? - Zero or one (optional)
  • {n} - Exactly n times
  • {n,} - n or more times
  • {n,m} - Between n and m times

Anchors

  • ^ - Start of string (or line with m flag)
  • $ - End of string (or line with m flag)
  • \b - Word boundary

Groups

  • (abc) - Capturing group
  • (?:abc) - Non-capturing group
  • a|b - Alternation (a or b)

Safety Features

Our tester includes protections against "catastrophic backtracking"—a situation where certain regex patterns can cause the engine to take an extremely long time or freeze. If your pattern causes excessive processing, the test will be stopped with a helpful error message.

Privacy and Security

All regex testing happens entirely in your browser. Your patterns and test text never leave your computer, making this tool safe for testing patterns against sensitive data.

Common Use Cases

Data Validation

Test patterns for validating user input like email addresses, phone numbers, postal codes, or custom formats.

Log Analysis

Develop patterns to extract specific information from log files, such as timestamps, error codes, or user IDs.

Text Parsing

Create patterns to parse structured text formats and extract the data you need.

Search and Replace

Test regex patterns before using them in find-and-replace operations in your IDE or text editor.

Learning Regex

Experiment with regex syntax in a safe environment with immediate visual feedback.

Pattern Debugging

Debug regex patterns that aren't matching as expected by seeing exactly what they match.

Worked Examples

Email Validation

Input

Pattern: [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}

Text: Contact us at [email protected] or [email protected] for help.

Output

Match 1: [email protected] (position 14)
Match 2: [email protected] (position 36)

The pattern matches email addresses by looking for characters before @, a domain name, and a top-level domain of at least 2 characters.

Extracting Numbers

Input

Pattern: \d+

Text: Order #12345 contains 3 items totaling $99.99

Output

Match 1: 12345 (position 7)
Match 2: 3 (position 22)
Match 3: 99 (position 40)
Match 4: 99 (position 43)

The \d+ pattern matches one or more consecutive digits. Note how 99.99 produces two matches because the decimal point is not a digit.

Frequently Asked Questions

What regex flavor does this tester use?

Our tester uses JavaScript's native regular expression engine, which follows the ECMAScript specification. Most regex syntax is compatible across languages, but some advanced features may differ.

Why did my regex cause a timeout error?

Some regex patterns can cause "catastrophic backtracking" where the engine takes exponentially longer with certain inputs. Our safety limits stop patterns that take too long. Try simplifying your pattern or using more specific character classes.

How do I match a literal special character like . or *?

Escape special characters with a backslash. To match a literal period, use \. instead of just a period. The special characters that need escaping are: . * + ? ^ $ { } [ ] ( ) | \

What's the difference between .* and .*?

Both match any characters, but .* is greedy (matches as much as possible) while .*? is lazy (matches as little as possible). The lazy version is often more useful when you have a specific ending pattern.

Can I test regex for other programming languages?

Most basic regex syntax is universal. However, some languages have unique features or slightly different escape rules. For language-specific behavior, test in that language's environment.

Is my test data secure?

Yes, all testing happens in your browser. No regex patterns or test text are ever sent to any server. You can safely test patterns against sensitive data.