Total Matches: 0

Match Details:

Capture groups will appear here when matches contain groups.

Key Features

🔍 Live Matching

See matches highlighted in real-time as you type your regex pattern.

📊 Detailed Results

View match positions, captured groups, and replacement results.

⚙️ Flag Support

Toggle regex flags (g, i, m, u) for different matching behaviors.

⚡ Interactive Testing

Test and debug regular expressions instantly with visual feedback.

Frequently Asked Questions

Getting Started

What is a regular expression?

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

How do I use this regex tester?

Enter your regex pattern in the "Regular Expression" field, enter test text in the "Test String" field, and see live matches highlighted. Toggle flags (g, i, m, u) to modify matching behavior. Use the Replace tab to test replacements.

Is my data safe?

Yes. All regex testing happens locally in your browser using JavaScript. Your patterns and test strings never leave your device or get sent to any server.

Regex Flags

What do the flags mean?

g (global): Find all matches, not just the first. i (case-insensitive): Match uppercase and lowercase. m (multiline): ^ and $ match start/end of lines. u (unicode): Enable full Unicode matching.

When should I use the global flag?

Use the global (g) flag when you want to find ALL matches in the text. Without it, the regex stops after finding the first match. It's essential for find-and-replace operations and counting all occurrences.

What is the case-insensitive flag?

The case-insensitive (i) flag makes the pattern match both uppercase and lowercase letters. For example, /test/i matches "test", "TEST", "Test", etc. Useful for user input validation.

Common Patterns & Examples

Example: Email validation

Pattern:

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

Matches: user@example.com, name.last@company.co.uk

Explanation: Matches word characters before @, domain name, and TLD.

Example: Phone number (US)

Pattern:

\b\d{3}[-.]?\d{3}[-.]?\d{4}\b

Matches: 123-456-7890, 987.654.3210, 5551234567

Explanation: 3 digits, optional separator, 3 digits, optional separator, 4 digits.

Example: URL matching

Pattern:

\b(?:https?://|www\.)[^\s]+\b

Matches: https://example.com, www.test.org/path

Example: Password strength

Pattern:

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

Requirements: Min 8 chars, uppercase, lowercase, number, special char.

Capture Groups & Replacement

How do capture groups work?

Capture groups (parentheses ()) extract specific parts of a match. Group 0 is the full match, group 1 is the first capture, group 2 is the second, etc. Use them to extract data or in replacements with $1, $2, etc.

Example: Extract name and domain from email

Pattern: (^[\w.-]+)@([\w.-]+\.[A-Za-z]{2,})$

Input: user@example.com

Group 1: user (name)

Group 2: example.com (domain)

How do replacements work?

In the Replace tab, enter a replacement pattern using $1, $2 to reference capture groups, or plain text for static replacement. Click "Apply Replacement" to see the result.

Special Characters

What characters need escaping?

Special characters . * + ? ^ $ ( ) [ ] { } | \ must be escaped with a backslash \ to match literally. For example, \. matches a literal period.

Common character classes

\d = digit (0-9), \w = word char (a-z, A-Z, 0-9, _), \s = whitespace, . = any char (except newline), ^ = start, $ = end.

What are quantifiers?

* = 0 or more, + = 1 or more, ? = 0 or 1, {n} = exactly n, {n,} = n or more, {n,m} = between n and m.