🔍

Regex Tester

Test and debug regular expressions with real-time matching and highlighting

Regular Expression Pattern

/ /
g - Global (all matches)
i - Case-insensitive
m - Multiline
s - Dotall
u - Unicode

📝 Test String

0 characters 0 lines

📚 Common Regex Patterns

Click any pattern to use it instantly

📧

Email Address

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

Validates email addresses

🔗

URL

^https?:\/\/(www\.)?...

Matches HTTP/HTTPS URLs

📱

Phone Number (US)

^\d{3}-\d{3}-\d{4}$

Format: 123-456-7890

🔒

Strong Password

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)...

Min 8 chars, upper, lower, digit, special

📮

ZIP Code

^[0-9]{5}(?:-[0-9]{4})?$

US ZIP codes (5 or 9 digits)

🎨

Hex Color

^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Hex color codes with/without #

🌐

IPv4 Address

^(?:(?:25[0-5]|2[0-4][0-9]...)\.){3}...

Validates IPv4 addresses

📅

Date (YYYY-MM-DD)

^\d{4}-\d{2}-\d{2}$

ISO date format

🇬🇧

UK Postcode

^[A-Z]{1,2}\d{1,2}\s?\d[A-Z]{2}$

UK postal codes

💳

Credit Card

^\d{16}$

16-digit card number

👤

Username

^[a-zA-Z0-9_]{3,16}$

Alphanumeric, 3-16 chars

💰

Currency/Price

^\$?[\d,]+\.?\d{0,2}$

Dollar amounts with decimals

About Regex Tester

The Regex Tester is a powerful, interactive tool for testing and debugging regular expressions in real-time. Whether you're a developer validating user input, a data analyst parsing text, or learning regex patterns, this tool provides instant visual feedback with highlighted matches, detailed statistics, and a comprehensive pattern library.

What are Regular Expressions?

Regular expressions (regex or regexp) are sequences of characters that define search patterns. They're used for text searching, validation, extraction, and replacement. Regex is supported in virtually all programming languages and is essential for tasks like form validation, log parsing, and data extraction.

How to Use This Tool

  1. Enter Pattern: Type your regex pattern in the top field between the slashes (/pattern/)
  2. Select Flags: Choose flags like global (g), case-insensitive (i), or multiline (m)
  3. Add Test Text: Enter or paste the text you want to test against your pattern
  4. View Results: Matches are highlighted in yellow instantly as you type
  5. Analyze Matches: See detailed statistics including match count, characters matched, and coverage percentage
  6. Use Quick Patterns: Click any pattern from the library to test common regex instantly

Regex Flags Explained

  • g (global): Find all matches rather than stopping after the first match
  • i (case-insensitive): Makes the pattern case-insensitive (A and a are the same)
  • m (multiline): ^ and $ match the start/end of each line, not just the whole string
  • s (dotall): Allows . to match newline characters
  • u (unicode): Treat pattern as a sequence of Unicode code points

Common Regex Syntax

Character Classes

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

Quantifiers

  • * - 0 or more times
  • + - 1 or more times
  • ? - 0 or 1 time (optional)
  • {n} - Exactly n times
  • {n,} - n or more times
  • {n,m} - Between n and m times

Anchors

  • ^ - Start of string/line
  • $ - End of string/line
  • \b - Word boundary
  • \B - Not word boundary

Groups & Lookarounds

  • (abc) - Capturing group
  • (?:abc) - Non-capturing group
  • (?=abc) - Positive lookahead
  • (?!abc) - Negative lookahead
  • a|b - a or b

Features

  • Real-time Testing: See results instantly as you type your pattern or test string
  • Visual Highlighting: Matches are highlighted in yellow for easy identification
  • Detailed Statistics: View total matches, characters matched, and coverage percentage
  • Match Details: See each match individually with its position and content
  • Multiple Flags: Support for all standard JavaScript regex flags (g, i, m, s, u)
  • Pattern Library: 12+ pre-made patterns for common use cases
  • Error Messages: Clear error descriptions for invalid regex syntax
  • Export Functionality: Download match results for further analysis

Common Use Cases

  • Form Validation: Validate email addresses, phone numbers, passwords, and other user input
  • Data Extraction: Extract specific patterns from logs, documents, or API responses
  • Text Processing: Find and replace text patterns in large documents
  • URL Routing: Match URL patterns for web applications and APIs
  • Log Parsing: Extract information from server logs, error messages, or system outputs
  • Learning Regex: Practice and experiment with regex patterns in a safe environment

Tips for Writing Better Regex

  • Start Simple: Begin with basic patterns and gradually add complexity
  • Use Anchors: Use ^ and $ to match entire strings, preventing partial matches
  • Be Specific: [0-9] is more specific than \d when you only want digits
  • Test Edge Cases: Try empty strings, special characters, and unexpected input
  • Escape Special Characters: Use \ before . * + ? [ ] { } ( ) | ^ $ to match them literally
  • Use Non-Capturing Groups: (?:) when you don't need to capture the group

Privacy & Security

100% Client-Side Processing: All regex testing happens entirely in your browser using JavaScript. Your patterns and test strings never leave your device or get sent to any server. This makes the tool completely safe for testing with sensitive data, API keys, or confidential information.