Regex Tester & Debugger

Test and debug regular expressions with real-time highlighting. Find matches, get explanations, and learn how to use regex effectively.

Regular Expression

//

Match Results:

No text to match

Code Implementation

JavaScript

const regex = new RegExp('your_pattern_here', 'g');
const matches = myString.match(regex);

Python

import re
pattern = r'your_pattern_here'
matches = re.findall(pattern, my_string)

PHP

<?php
$pattern = '/your_pattern_here/m';
preg_match_all($pattern, $text, $matches);
?>

Regex Patterns Library

Common patterns to help you get started. Click any pattern to use it.

Email

Match a valid email address

^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$

URL

Match a URL with optional protocol

^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$

IP Address

Match an IPv4 address

^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$

Phone Number

Match common phone number formats

^[\+]?[(]?[0-9]{3}[)]?[-\s\.]?[0-9]{3}[-\s\.]?[0-9]{4,6}$

Date (YYYY-MM-DD)

Match a date in YYYY-MM-DD format

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$

HTML Tag

Basic HTML tag matcher

<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)

Password Strength

Match a strong password (min 8 chars, uppercase, lowercase, number, special char)

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$

Username

Match a username (3-16 characters, alphanumeric, underscore, hyphen)

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

Hex Color

Match a hex color code

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

Credit Card Number

Match major credit card numbers

^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})$

Regex Cheatsheet

Character Classes

  • \d - Match a digit
  • \w - Match a word character
  • \s - Match a whitespace character
  • [abc] - Match any character in the set
  • [^abc] - Match any character not in the set

Quantifiers

  • * - Match 0 or more times
  • + - Match 1 or more times
  • ? - Match 0 or 1 time
  • {n} - Match exactly n times
  • {n,} - Match at least n times
  • {n,m} - Match between n and m times

Anchors

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

Flags

  • g - Global search (find all matches)
  • i - Case-insensitive search
  • m - Multi-line mode (^ and $ match line starts/ends)
  • s - Dot (.) matches newlines

How to Use the Regex Tester

Step 1: Enter Your Pattern

Type or paste your regular expression pattern in the input field. The tool supports all standard regex syntax including character classes, quantifiers, groups, and assertions. You can also select from our library of common patterns.

Step 2: Add Test String

Enter the text you want to test against your pattern. Matches will be highlighted in real-time as you type, making it easy to see exactly what your regex is capturing.

Step 3: Configure Flags

Select the appropriate flags for your use case. Common flags include 'g' for global matching, 'i' for case-insensitive matching, and 'm' for multiline mode.

Step 4: Export Your Pattern

Once your regex is working correctly, copy it to your clipboard or generate code snippets for JavaScript, Python, PHP, and other programming languages.

Frequently Asked Questions

What is regex (regular expression)?

A regular expression (regex) is a sequence of characters that defines a search pattern. It's commonly used for string matching, validation, and text manipulation in programming and data processing.

What are regex flags?

Regex flags modify how a pattern is interpreted. Common flags include 'g' (global - find all matches), 'i' (case-insensitive), 'm' (multiline - ^ and $ match line breaks), 's' (dotall - . matches newlines), and 'u' (unicode support).

How do I match special characters?

Special characters like ., *, +, ?, [, ], {, }, (, ), |, \, ^, and $ have special meanings in regex. To match them literally, escape them with a backslash (\). For example, \. matches a literal period.

What's the difference between greedy and lazy matching?

Greedy quantifiers (*, +, ?) match as much as possible, while lazy quantifiers (*?, +?, ??) match as little as possible. For example, .* is greedy and will match everything it can, while .*? is lazy and stops at the first opportunity.

Can I use this tool for email validation?

Yes! We provide a pre-built email validation pattern in our Common Patterns library. However, note that complete email validation is complex - for production use, consider using dedicated email validation libraries.

Regex Tester Features

Real-Time Testing

See matches highlighted instantly as you type. No need to click a button - the regex engine processes your patterns in real-time.

Code Generation

Generate ready-to-use code snippets for JavaScript, Python, PHP, and other languages with proper escaping and syntax.

Pattern Library

Access a curated collection of common regex patterns for emails, URLs, phone numbers, and more. Learn by example.

Unlock 150,000+ Tool Ideas & Resources

Get instant access to our massive database of tool ideas, Chrome extensions, prompts, and proven strategies to build your next successful SaaS.

One-time payment • Instant access • 7-day refund guarantee