Home/Developer Tools/Regex Tester

Regex Tester

Test and debug regular expressions with live match highlighting, capture groups, and replacement preview. Instantly see all matches and details. Your data is processed locally in your browser and never uploaded.

Enter a JavaScript regular expression pattern (without slashes). For example: ^\w+@\w+\.\w+$

Paste or enter the text you want to test against the regex pattern.

How to Use the Regex Tester

  1. 1. Enter a regex pattern

    Type your regular expression pattern without the forward slashes. For example: ^\w+@[\w.]+$ to match email-like patterns.

  2. 2. Set flags (optional)

    Choose regex flags: g for global (find all matches), i for case-insensitive, m for multiline, or s for dot-all mode.

  3. 3. Enter text to test

    Paste or type the text you want to test against your pattern. All processing happens in your browser.

  4. 4. View results and replace

    See all matches highlighted in the text, with details like position and capture groups. Optionally preview a replacement.

Regular Expression Basics

A regular expression (regex) is a pattern that matches characters in text. Use special characters to create powerful search and validation rules.

Character Classes

  • [abc] - Match a, b, or c
  • [a-z] - Match any lowercase letter
  • [^abc] - Match anything except a, b, or c
  • \d - Match any digit (0-9)
  • \w - Match word characters (a-z, 0-9, _)
  • \s - Match whitespace

Quantifiers

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

Anchors & Boundaries

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

Groups & Alternation

  • (pattern) - Capture group
  • (?:pattern) - Non-capturing group
  • a|b - Match a or b
  • . - Any character (except newline)

Common Regex Patterns

Email Address

Validates basic email format

Pattern:

^[\w.-]+@[\w.-]+\.\w+$

Example: [email protected]

URL

Matches HTTP/HTTPS URLs

Pattern:

^https?:\/\/[\w.-]+\.[a-z]{2,}

Example: https://example.com/path

Phone Number (US)

Matches various US phone formats

Pattern:

^\(?\d{3}\)?[- ]?\d{3}[- ]?\d{4}$

Example: (555) 123-4567

Date (YYYY-MM-DD)

Matches ISO date format

Pattern:

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

Example: 2024-10-25

Hex Color

Matches hex color codes

Pattern:

^#?[0-9a-fA-F]{6}$

Example: #FF5733 or FF5733

Words Only

Matches text with letters and spaces only

Pattern:

^[a-zA-Z\s]+$

Example: Hello World

Understanding Flags

g

Global

Find all matches in the string. Without this flag, only the first match is returned.

i

Case-Insensitive

Match uppercase and lowercase characters. For example, /hello/i matches "HELLO", "Hello", and "hello".

m

Multiline

Make ^ and $ match the start/end of lines, not just the start/end of the entire string. Useful for multiline text.

s

Dot All

Make the . metacharacter match any character, including newlines. By default, . matches any character except newlines.

When to Use Regex Tester

Validate Input

Test regex patterns for form validation, such as email, phone numbers, and password requirements.

Extract Data

Use capture groups to extract specific parts of text, like domain from URLs or area code from phone numbers.

Find & Replace

Test replacement patterns before using them in code to transform text or reformat data.

Debug Patterns

Troubleshoot regex patterns by testing them with real data and viewing detailed match results.

Learn Regex

Experiment with different patterns and see immediate results. Perfect for learning regex syntax and behavior.

Text Search

Search for complex patterns in large text, logs, or code. See all matches highlighted and detailed.

This tool uses JavaScript regular expressions. The RegExp syntax is largely consistent across programming languages, but some advanced features may differ. Test patterns for your specific language or framework.