All tools

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.
Pattern
Flags
Test text
Output
[0] Hello [6] world [12] 123

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.

When to avoid regex

When parsing HTML or JSON — use proper parsers.
When regex becomes unreadable — split into code logic.
When ReDoS risk on user-supplied patterns in server — timeout and limit length.

ReDoS awareness

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

Validate vs extract

Anchored pattern ^...$ validates whole string; unanchored finds substring anywhere.

Replace in editors

VS Code uses similar JS regex in find-replace — test here then paste pattern.

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.

Multiline ^ $?

m flag makes ^ $ match line boundaries not whole string.