Regex Tester

Test and debug regular expressions in real-time. Visualize matches, get explanations, and learn regex patterns.

Regular Expression Pattern

Test String

Total Matches
0
Pattern
/pattern/
Flags
g
Test Time
0ms

Regex Pattern Explanation

Replace Matches

Replaced Result:

Regex Cheatsheet

Character Classes

. Any character except newline
\d Digit (0-9)
\w Word character (a-z, A-Z, 0-9, _)
\s Whitespace (space, tab, newline)
[abc] Any of a, b, or c

Quantifiers

* 0 or more
+ 1 or more
? 0 or 1
{3} Exactly 3
{3,5} Between 3 and 5

Anchors

^ Start of string
$ End of string
\b Word boundary
\B Not word boundary

Groups & Lookarounds

(abc) Capture group
(?:abc) Non-capturing group
(?=abc) Positive lookahead
(?!abc) Negative lookahead

Email Validation

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

Phone Number

(\+\d{1,3}[-.]?)?\(?\d{3}\)?[-.]?\d{3}[-.]?\d{4}
Matches various phone number formats

URL Pattern

https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)
Matches HTTP/HTTPS URLs

Date (YYYY-MM-DD)

\d{4}-\d{2}-\d{2}
Matches dates in YYYY-MM-DD format

IP Address

\b(?:\d{1,3}\.){3}\d{1,3}\b
Matches IPv4 addresses

Strong Password

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
At least 8 chars with upper, lower, number & special

About Regular Expressions

Regular expressions (regex) are patterns used to match character combinations in strings. They are incredibly powerful for text processing, validation, and extraction.

Common Use Cases:

  • Form Validation: Validate emails, phone numbers, passwords
  • Data Extraction: Extract specific information from text
  • Search & Replace: Find and replace patterns in text
  • Text Parsing: Parse log files, configuration files
  • Input Sanitization: Remove unwanted characters from input
  • URL Routing: Match URL patterns in web frameworks

Key Features of This Tester:

  • Real-time Testing: See matches as you type
  • Visual Highlighting: Matches are highlighted in the test string
  • Detailed Explanation: Understand how your regex works
  • Capture Groups: View and test capture groups
  • Replace Functionality: Test regex replace operations
  • Cheatsheet: Quick reference for regex syntax
  • Examples: Common regex patterns to learn from
  • History: Save and reuse your regex patterns

Performance Tips:

  • Be Specific: Use precise character classes instead of .*
  • Avoid Catastrophic Backtracking: Use possessive quantifiers when possible
  • Use Anchors: Use ^ and $ when matching entire strings
  • Optimize Groups: Use non-capturing groups (?:) when you don't need capture
  • Test Edge Cases: Always test with both valid and invalid inputs

Browser Compatibility:

This tool uses JavaScript's built-in RegExp engine, which is supported in all modern browsers. Some advanced features (like lookbehind) may have limited browser support.

Note: All processing happens in your browser. Your data never leaves your computer, ensuring complete privacy.

Ad Space (300x250)

Related Developer Tools

Quick Reference

Digits\d
Word\w
Whitespace\s
0 or more*
1 or more+

Common Flags

g - Global match

i - Case insensitive

m - Multiline

u - Unicode