Regular expression generator with examples
Choose the data type, copy the pattern and check how it behaves with an actual value. Each part of the regex is explained so that you can adapt it.
Workspace · Regular expression generator
/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/
| Fragmento | Qué hace |
|---|---|
| ^ … $ | Ancla el inicio y el final: evita aceptar texto sobrante. |
| [A-Za-z0-9._%+-]+ | Usuario: letras, números y los signos habituales. |
| @[A-Za-z0-9.-]+ | Dominio, con al menos un punto. |
| \.[A-Za-z]{2,} | Extensión de dos letras o más. |
Coincide con el patrón
Estos patrones son puntos de partida. Para validar correos, URLs o teléfonos reales combina la regex con una comprobación adicional (por ejemplo, verificación de DNS o de formato E.164): una expresión regular no demuestra que un dato exista. Prueba cualquier variante en el probador de regex.
How to use it
Select the type of pattern you need from the list of options.
Copy the generated expression or edit it in your editor.
Test the actual variants in the test environment before deploying them to production.
Examples
Contact form
The email format requires a username, an @ symbol, a domain name and an extension of two letters or more, with no spaces.
Validate a slug
The slug pattern only allows lower-case letters, numbers and single hyphens between blocks.
What you need to know
A regular expression describes the format of a text, not its accuracy. Just because an email address matches the pattern does not mean the account exists; just because a URL appears valid does not guarantee that it will respond. For critical data, combine the regex with an additional check.
The patterns on this page are anchored with ^ and $ when used to validate an entire field. If you use them to search within a longer text, remove the anchors or use the appropriate word limits.
Frequently Asked Questions
Related tools
Other tools that can help with similar tasks.
Regular expression tester
Test regex patterns with modifiers, capture groups and live highlighting.
JavaScript Validator
Detect syntax errors in your code without running it, with line numbers and helpful warnings.
Fake data generator
Generate sample names, email addresses, telephone numbers and addresses in CSV or JSON format.
