Tools / Regex Tester

๐Ÿงช Regex & Test Input

๐Ÿ“‹ Results

Enter a pattern and test string to see results

๐Ÿ“š About Regular Expressions

Master regular expressions with this comprehensive guide and testing tool

What is a Regular Expression?

A regular expression (or regex/regexp) is a sequence of characters that define a search pattern. Used for:

  • Pattern matching: Find specific text patterns
  • Validation: Validate email, phone, dates, etc.
  • Text extraction: Extract data from text
  • Search and replace: Find and replace patterns
  • Data cleaning: Clean and format data
  • Parsing: Parse structured text data

Basic Syntax

Literal: abc - matches "abc"

Dot: a.c - matches "abc", "adc", etc.

Character class: [abc] - matches a, b, or c

Negation: [^abc] - matches any char except a, b, c

Range: [a-z] - matches lowercase letters

Quantifiers

* - 0 or more times

+ - 1 or more times

? - 0 or 1 time (optional)

{n} - exactly n times

{n,m} - between n and m times

{n,} - n or more times

Anchors & Escapes

^ - start of string

$ - end of string

\b - word boundary

\d - digit [0-9]

\w - word char [a-zA-Z0-9_]

\s - whitespace

Common Regex Patterns

๐Ÿ“ง Email Address
^[^\s@]+@[^\s@]+\.[^\s@]+$
๐Ÿ“ฑ Phone (US Format)
^\+?1?\d{9,15}$
๐Ÿ”— URL
^https?:\/\/.+\..+$
๐Ÿ“… Date (YYYY-MM-DD)
^\d{4}-\d{2}-\d{2}$
๐Ÿ’ณ Credit Card
^\d{4}[\s-]?\d{4}[\s-]?\d{4}[\s-]?\d{4}$
๐Ÿ” Strong Password
^(?=.*[A-Z])(?=.*\d).{8,}$

Groups & Capture

(abc) - capture group

(?:abc) - non-capturing group

(?=abc) - positive lookahead

(?!abc) - negative lookahead

\1, \2 - back references

Alternation & Operators

| - OR operator (cat|dog)

\ - escape special chars

. - any character except newline

- - range in character class

How to Use This Regex Tester

๐Ÿ” Step-by-Step Guide:
  1. Enter your regular expression pattern in the Pattern field
  2. Enter the text to test against in the Text area
  3. Select regex flags if needed (g, i, m, s)
  4. Click Test to see matches
  5. View matches highlighted in the output with details
  6. Adjust pattern and re-test as needed

Regex Flags & Modifiers

g - Global (find all matches)

i - Case insensitive matching

m - Multiline (^ and $ per line)

s - Dot matches newlines

u - Unicode matching

y - Sticky matching

Tips & Best Practices

  • Start simple, then add complexity
  • Test with edge cases
  • Use non-greedy matching (.*?) when needed
  • Escape special characters properly
  • Comment complex patterns
  • Use tools to visualize patterns

Common Regex Mistakes

โŒ Greedy Quantifiers

Problem: .* matches too much. Solution: Use .*? for non-greedy matching.

โŒ Unescaped Special Chars

Problem: . matches any char. Solution: Use \. to match literal dot.

โŒ Wrong Flags

Problem: Case sensitive when not needed. Solution: Use 'i' flag for case-insensitive.

โŒ Missing Global Flag

Problem: Only finds first match. Solution: Add 'g' flag to find all.

Advanced Features

  • Lookahead: (?=pattern)
  • Lookbehind: (?<=pattern)
  • Named groups: (?P<name>...)
  • Unicode escapes: \uXXXX
  • Backreferences: \1, \2

Related Tools

Email Contact Form GitHub LinkedIn