Regex Tester

100% Client-Side Instant Result

Your results will appear here.

Ready to run.
Verified

About this tool

What Is a Regex Tester?

A regex tester lets you write a regular expression pattern and test it against sample text to see which parts match, where matches occur, and which groups are captured. It is an essential debugging tool for developers, data analysts, and anyone working with pattern matching in text.

Regex (Regular Expressions) is a pattern matching language supported by virtually every programming language, text editor, and database system.

Common Regex Patterns

| Pattern | Matches | Example |
|---|---|---|
| \d{3}-\d{3}-\d{4} | US phone number | 555-123-4567 |
| [\w.]+@[\w.]+\.[a-z]{2 } | Email address | user@example.com |
| \b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b | IPv4 address | 192.168.1.1 |
| https?:/[^\s]+ | URL | https://example.com |
| \d{4}-\d{2}-\d{2} | ISO date |-01-15 |
| ^[A-Z][a-z]+$ | Capitalized word | Hello |

Regex Flag Reference

  • g (global): Find all matches, not just the first one. Most common flag.
  • i (case-insensitive): Match regardless of letter case. "hello" matches "HELLO".
  • m (multiline): ^ and $ match line beginnings/endings, not just string start/end.
  • s (dotAll): The dot (.) matches newline characters too.
  • u (unicode): Treat pattern and string as Unicode. Required for matching emoji.
  • y (sticky): Match only at the lastIndex position.
Advertisement

Practical Usage Examples

Email Validation

Match email addresses

Pattern: [\w.]+@[\w.]+\.[a-z]{2 } Flags: gi

Step-by-Step Instructions

Step 1: Enter Pattern. Type your regular expression in the Pattern field (e.g., \d{3}-\d{3}-\d{4} for US phone numbers).

Step 2: Enter Test String. Paste the text you want to test against in the Test String field.

Step 3: Set Flags. Enter regex flags: g (global — find all matches), i (case-insensitive), m (multiline), s (dotAll), u (unicode), y (sticky).

Step 4: View Matches. See all matches with their positions and captured groups. Zero matches returns a "No matches found" message.

Step 5: Read Analysis. The tool analyzes your pattern complexity and provides optimization tips.

Core Benefits

Instant Match Results: Tests your regex against the test string immediately, showing every match position and captured group.

All JavaScript Flags: Supports g (global), i (case-insensitive), m (multiline), s (dotAll), u (unicode), and y (sticky) flags.

Pattern Analysis: Evaluates pattern complexity, identifies metacharacters used (\d, \w, \s), and suggests improvements like adding the global flag.

Safe Execution: Limits matches to 1,000 results and handles catastrophic backtracking scenarios by preventing infinite loops.

Frequently Asked Questions

Flags modify matching behavior. Use "g" (global) to find ALL matches instead of just the first. Use "i" for case-insensitive matching. Use "m" for multiline mode where ^ and $ match line boundaries. Use "gi" together for global case-insensitive matching.

Common issues: (1) Forgetting to escape special characters like . * + ? with backslash. (2) Missing the "g" flag so only the first match is found. (3) Anchors ^ and $ preventing partial matches. (4) Overly strict character classes.

matches zero or more occurrences (the preceding element is optional). + matches one or more occurrences (at least one is required). For example, \d matches "" (empty) and "123", while \d+ requires at least one digit.

A simple pattern: [\w.+-]+@[\w-]+\.[a-zA-Z]{2 }. This matches most common email formats. For RFC 5322 compliant matching, regex becomes extremely complex. For production use, combine simple regex with server-side validation.

Backslash escapes special characters, making them literal (\. matches an actual dot instead of "any character"). It also creates metacharacters: \d (digit), \w (word character), \s (whitespace), \b (word boundary).

Use parentheses () to create capturing groups. For example, (\d{3})-(\d{4}) captures the area code and number separately. Access captured groups in the match results. Non-capturing groups use (?:...) syntax.

Catastrophic backtracking occurs when nested quantifiers create exponential matching attempts (e.g., (a+)+ against "aaab"). This can freeze the browser. Avoid nested quantifiers and use atomic groups or possessive quantifiers when possible.

This tester uses JavaScript RegExp engine. Most basic patterns work identically in Python, Java, and PHP. Differences: JavaScript lacks lookbehind in older browsers, does not support named groups in all versions, and has slightly different flag syntax.

A practical pattern: https?:/[^\s]+. This matches http and https URLs until a space. For stricter validation: https?:/[\w.-]+\.[a-zA-Z]{2 }(/[\w./-]*)? validates the domain structure.

No. All regex testing runs in your browser using JavaScript RegExp. Your patterns and test strings are never transmitted to any server.

Related tools

View all tools