Testador de Expressões Regulares

Teste expressões regulares em texto de exemplo com destaque de correspondências em tempo real.

What is This Tool?

Regular expressions (regex) are patterns used to match character combinations in strings. They are essential for text searching, validation, and manipulation in programming. This tool lets you test patterns against sample text and see matches highlighted in real-time.

Formula
Common regex syntax: . = any character \d = digit (0-9) \w = word character (a-z, A-Z, 0-9, _) \s = whitespace * = 0 or more + = 1 or more ? = 0 or 1 [abc] = character class ^/$ = start/end of string () = capture group
Worked Examples

1. Match email addresses

Given: Pattern: [\w.+-]+@[\w-]+\.[\w.-]+

[\w.+-]+ matches the local part (before @)

@ matches the literal @ symbol

[\w-]+\.[\w.-]+ matches the domain

Result: Matches: user@example.com, john.doe+tag@mail.co.uk

2. Extract phone numbers

Given: Pattern: \d{3}[-.]?\d{3}[-.]?\d{4}

\d{3} matches 3 digits

[-.]? optionally matches dash or dot separator

Repeats for all groups

Result: Matches: 555-123-4567, 555.123.4567, 5551234567

3. Validate hex colors

Given: Pattern: ^#?([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$

^#? optionally matches leading #

[0-9A-Fa-f]{3} matches 3-digit shorthand

| or [0-9A-Fa-f]{6} matches full 6-digit

Result: Matches: #FFF, #FF5733, aabbcc

Frequently Asked Questions