🧩 Free Regex Tester

Test, visualize, and generate regex patterns instantly across multiple programming languages.

Preview Result
No matches yet...
Generate Regex Code

  

📖 Complete Regex Guide & Examples

Learn all common regex patterns, syntax, and examples with test text.

1. Characters & Classes

  • a, 1, @ — match literal characters
  • . — match any character except newline
  • [abc] — match 'a', 'b', or 'c'
  • [a-z] — lowercase letters
  • [^abc] — negation
  • \d — digits; \D — non-digits
  • \w — word characters; \W — non-word
  • \s — whitespace; \S — non-whitespace

2. Anchors

  • ^ — start of line
  • $ — end of line
  • \b — word boundary; \B — non-word boundary

3. Quantifiers

  • * zero or more; + one or more; ? optional
  • {n} exact n times; {n,} at least n; {n,m} between n and m

4. Groups & Captures

  • (abc) — capture; (?:abc) — non-capture
  • \1, \2... — backreference

5. Alternation / OR

  • cat|dog — match either cat or dog

6. Escaping Special Characters

  • \. — literal dot
  • \* — literal star

7. Lookahead / Lookbehind

  • (?=pattern) positive lookahead
  • (?!pattern) negative lookahead
  • (?<=pattern) positive lookbehind
  • (? negative lookbehind

8. Common Examples

  • Email: [\\w.-]+@[\\w.-]+\\.[A-Za-z]{2,} → test@example.com
  • Phone: \\+?[0-9]{10,15} → +12345678901
  • Date YYYY-MM-DD: \\d{4}-\\d{2}-\\d{2} → 2025-11-05
  • Hex Color: #([0-9a-fA-F]{3}|[0-9a-fA-F]{6}) → #fff, #abcdef
  • IP: (?:\\d{1,3}\\.){3}\\d{1,3} → 192.168.0.1
  • Time HH:MM: ([01]?\\d|2[0-3]):[0-5]\\d → 13:45
  • URL: https?:\\/\\/[\\w.-]+ → https://example.com

❓ Frequently Asked Questions (FAQ)

Q: How do I match an email address?

A: Use [\\w.-]+@[\\w.-]+\\.[A-Za-z]{2,}. Test in the input above.

Q: Can I match multiple lines?

A: Check "Global search" or add flags in your code. "^" and "$" respect line positions.

Q: What is the difference between \\d and \\w?

A: \\d matches digits 0-9, \\w matches letters, digits, and underscore.

Q: How do I escape special characters?

A: Use a backslash: \\., \\*, \\?.