Regex tester

Regular expressions pattern-match text for validation, search-replace, and log parsing. Test patterns with live highlighting before dropping into production code — avoid catastrophic backtracking surprises on user input.

How to test a regex

1. Enter regex pattern (without outer slashes or with flags).
2. Set flags: g global, i case insensitive, m multiline.
3. Paste sample text in test string area.
4. Review matches, capture groups, and replace preview if available.

Regex examples

Email-ish validation

^[\w.-]+@[\w.-]+\.\w+$ catches simple emails — not RFC-perfect but useful for forms.

Extract ISO dates

\d{4}-\d{2}-\d{2} finds 2024-03-15 in log lines for grep replacement.

Slugify helper

Replace [^a-z0-9]+ with hyphen for URL slug from title string.

When regex helps

• When validating structured strings (phone, postal code).
• When parsing semi-structured logs.
• When learning capture groups and lookahead.

ReDoS awareness

Nested quantifiers like (a+)+ on evil string hang CPU — avoid user regex on server or use safe engines with timeouts.

Frequently asked questions

Which regex flavor?

JavaScript RegExp — PCRE differences exist (lookbehind support varies by engine version).

Global flag g?

Finds all matches not just first — testStateful with lastIndex in JS.

Escape special chars?

. * + ? [ ] ( ) { } | \ ^ $ need escaping for literal match.

Capture groups?

Parentheses ( ) create numbered groups accessible in replace $1 $2.

Local?

Yes.