Testador e Validador de Expressões Regulares
Voltar para FerramentasAbout Regex Tester
Teste, depure e valide expressões regulares com correspondência em tempo real. Perfeito para validação de padrões em formulários, extração de dados e processamento de texto. Suporta flags globais, insensível a maiúsculas e multilinha.
Key Features
- Real-time pattern matching and validation
- Support for all PHP regex functions (preg_match, preg_match_all, preg_replace, preg_split)
- Multiple pattern modifiers and flags
- Detailed match results with highlighting
- Copy results and patterns easily
How to Use
- Enter your regex pattern (e.g.,
/\d+/) - Add test text to match against
- Select the PHP function to test
- Choose modifiers and flags as needed
- Click "Process" to see results
Pro Tip: Use the educational sections below to learn regex patterns, see common examples, and avoid typical mistakes. Perfect for beginners and experienced developers alike!
Exemplos de Regex
Email Validation
/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/
Phone Number
/\+?[1-9]\d{1,14}$|^\(\d{3}\)\s?\d{3}-\d{4}$/
URL Validation
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)/
Date Format
/^\d{4}-\d{2}-\d{2}$|^\d{2}\/\d{2}\/\d{4}$/
IP Address
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
Credit Card
/^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}|3[0-9]{13}|6(?:011|5[0-9]{2})[0-9]{12})$/
Folha de Consulta Regex
Metacharacters
. - Any character^ - Start of line$ - End of line* - 0 or more+ - 1 or more? - 0 or 1| - OR operatorQuantifiers
{n} - Exactly n times{n,} - n or more times{n,m} - Between n and m* - 0 or more (greedy)*? - 0 or more (lazy)+ - 1 or more (greedy)+? - 1 or more (lazy)Anchors
^ - Start of string$ - End of string\b - Word boundary\B - Non-word boundary\A - Start of string\Z - End of string\z - Absolute endCharacter Classes
[abc] - Any of a, b, c[a-z] - Any lowercase letter[A-Z] - Any uppercase letter\d - Any digit [0-9]\w - Any word character\s - Any whitespace\D - Non-digitDicas para Testar Regex
- Start with simple patterns and gradually add complexity
- Use test strings that include edge cases
- Test both positive and negative matches
- Consider performance with large text inputs
Erros Comuns de Regex
- Forgetting to escape special characters
- Not considering case sensitivity
- Overusing greedy quantifiers
- Missing anchor points for exact matches