~welcome
regex-tester

Regex Tester

test · match · highlight · capture

// common patterns

$ how-to-use

Enter your regex pattern and test string. Matches are highlighted in real-time. Toggle flags (global, case-insensitive, multiline) and view capture groups for each match.

Why Use a Regex Tester?

Regular expressions are powerful but notoriously hard to get right on the first try. A single misplaced character can change what a pattern matches entirely. Testing in a live environment lets you iterate quickly without running your full application.

This tool highlights matches instantly as you type, shows capture group contents, and supports all JavaScript regex flags. It's faster than console.log debugging and safer than testing against production data.

Common Regex Patterns

Email

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

URL

https?:\/\/[^\s/$.?#].[^\s]*

Phone Number

\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}

IP Address

\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b

Common Patterns Reference

Copy any pattern and test it above. These cover the most frequently needed validations in web development.

PatternRegexNotes
Email (simple)[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}Covers most real-world emails
URL (http/https)https?:\/\/[^\s/$.?#].[^\s]*Matches full URLs with protocol
US Phone\(?\d{3}\)?[-.\s]?\d{3}[-.\s]?\d{4}Handles (555) 123-4567 and variants
IPv4 Address\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\bBasic format check, not range validation
HEX Color#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})Matches #fff and #3fb950
ISO Date\d{4}-\d{2}-\d{2}YYYY-MM-DD format
HTML Tag<([a-z][a-z0-9]*)\b[^>]*>Opening tags only. Don't parse HTML with regex.
Integer^-?\d+$Positive or negative whole numbers
Floating Point^-?\d+\.?\d*$Numbers with optional decimal
File Extension\.(jpg|jpeg|png|gif|svg|webp)$Image files — customize extensions as needed
Slug / URL Path^[a-z0-9]+(-[a-z0-9]+)*$Lowercase, hyphens, no special chars

Regex Syntax Quick Reference

Character Classes

\d — Any digit (0-9)

\w — Word character (a-z, A-Z, 0-9, _)

\s — Whitespace (space, tab, newline)

\b — Word boundary

. — Any character except newline

[abc] — Character set (a, b, or c)

[^abc] — Negated set (not a, b, or c)

Quantifiers

* — 0 or more (greedy)

+ — 1 or more (greedy)

? — 0 or 1 (optional)

*? — 0 or more (lazy)

+? — 1 or more (lazy)

{3} — Exactly 3

{2,5} — Between 2 and 5

Anchors & Groups

^ — Start of string / line

$ — End of string / line

(abc) — Capture group

(?:abc) — Non-capturing group

(?=abc) — Positive lookahead

(?!abc) — Negative lookahead

a|b — Alternation (a or b)

JavaScript Flags

g — Global (find all matches)

i — Case insensitive

m — Multiline (^ and $ per line)

s — Dotall (. matches newline)

u — Unicode mode

d — Indices (match positions)

v — Unicode sets (new in ES2024)

Regex Performance Tips

Poorly written regex patterns can cause catastrophic backtracking, where the engine takes exponential time to determine that a string doesn't match. This happens when quantifiers are nested or when there are multiple ways the engine can match the same substring.

Avoid patterns like (a+)+$ or (a|aa)+$ — these create exponential backtracking on non-matching input. Instead, use atomic groups or possessive quantifiers where supported, or restructure to avoid ambiguity. In JavaScript, consider using String.prototype.includes() or String.prototype.startsWith() for simple substring checks instead of regex — they're faster and clearer.

FAQ

Which regex flavor is this?

JavaScript (ECMAScript). This covers most web development use cases. Note that some features like lookbehinds require modern browsers.

What are capture groups?

Parentheses () in a pattern create capture groups — they extract specific parts of a match. For example, (\d+)-(\d+) captures the two numbers separately from "123-456".

Is my data private?

Yes. All pattern matching runs in your browser. No data is sent anywhere.