Regex Tester

Test and debug regular expressions with real-time match highlighting, group captures, and replace mode

//g
Flags:
Mode:

Common Patterns

Matches

Regex Pitfalls Worth Knowing

Core concepts

  • Greedy matching: `.*` matches as much as possible β€” `<.*>` swallows all of `<a><b>`. Use `.*?` for lazy matching.
  • Anchors: without `^` and `$`, partial matches pass. Full-string validation needs `^...$`.
  • Escaping: to match `.`, `+`, `?`, `(`, `[` literally, escape them (`\.`).

The performance trap (ReDoS)

Nested quantifiers like `(a+)+` can go exponential on crafted input and take down a service (ReDoS). If a regex runs on user input server-side, keep the pattern simple.

Practical advice

There is no truly 'perfect' email or URL regex. Validate format loosely, then confirm by doing the real thing β€” sending the email, fetching the link. That design survives edge cases regex never will.

Frequently Asked Questions

Related Tools

Sources & References

Content last reviewed: 2026-08-22