¿Qué es un tester de expresiones regulares?
Un tester de regex (expresiones regulares) es una herramienta interactiva para escribir, probar y depurar patrones de búsqueda de texto. Te permite:
- Ver coincidencias en tiempo real mientras escribes
- Inspeccionar grupos de captura y sus valores
- Entender qué hace cada token del patrón
- Probar contra múltiples casos de prueba a la vez
- Detectar errores de sintaxis antes de usar el regex en producción
Anatomía de una expresión regular
/ ^ [a-z] + \. (com|org) $ / g i m
| | | | | | | | | | |
| | | | | | | | | | └─ flags
| | | | | | | | | └──── sticky (y)
| | | | | | | | └────── unicode (u)
| | | | | | | └───────── dotAll (s)
| | | | | | └──────────── multiline (m)
| | | | | | └───────────── case-insensitive (i)
| | | | | └──────────────────── global (g)
| | | | | └───────────────────── grupo captura: "com" u "org"
| | | | └──────────────────────────── carácter literal "."
| | | └──────────────────────────────── cuantificador: 1 o más
| | └───────────────────────────────────── clase: letras minúsculas
| └────────────────────────────────────────── ancla: inicio de string
└───────────────────────────────────────────── delimitadores (no parte del patrón)Flags disponibles en JavaScript
| Flag | Nombre | Efecto |
|---|---|---|
g |
Global | Encuentra todas las coincidencias, no solo la primera |
i |
Case-insensitive | Ignora mayúsculas/minúsculas |
m |
Multiline | ^ y $ coinciden con inicio/fin de línea, no solo de string |
s |
dotAll | . coincide también con salto de línea (\n, \r) |
u |
Unicode | Trata el patrón como código Unicode (necesario para \p{...}, emojis, etc.) |
y |
Sticky | Busca solo desde la posición lastIndex (rendimiento en parsing) |
Combinación común:
gim(global, case-insensitive, multiline) para búsquedas generales.
Presets incluidos
| Preset | Patrón | Qué valida |
|---|---|---|
^[^\s@]+@[^\s@]+\.[^\s@]+$ |
Formato básico email (RFC 5322 simplificado) | |
| URL | ^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$ |
URLs HTTP/HTTPS |
| IPv4 | `^((25[0-5] | 2[0-4][0-9] |
| DNI/NIE (ES) | ^[0-9]{8}[TRWAGMYFPDXBNJZSQVHLCKE]$ / ^[XYZ][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$ |
Documentos españoles |
| IBAN (ES) | ^ES[0-9]{22}$ |
IBAN español (formato, no valida dígitos de control) |
| Color Hex | `^#([0-9a-fA-F]{3} | [0-9a-fA-F]{6} |
| Fecha ISO | ^\d{4}-\d{2}-\d{2}$ |
YYYY-MM-DD (formato, no valida días reales) |
| Teléfono (ES) | `^(+34 | 0034)?[679]\d{8}$` |
El explicador token a token
El explicador descompone tu patrón y describe cada elemento:
| Tipo | Ejemplo | Explicación generada |
|---|---|---|
| Ancla | ^ |
“Inicio de string (o línea con flag m)” |
| Ancla | $ |
“Fin de string (o línea con flag m)” |
| Clase | [a-z] |
“Clase de caracteres: cualquier letra minúscula a-z” |
| Clase negada | [^0-9] |
“Clase negada: cualquier carácter EXCEPTO dígitos” |
| Escape | \d |
“Atajo: dígito (equivalente a [0-9])” |
| Escape | \. |
“Carácter literal: punto” |
| Cuantificador | + |
“Cuantificador: 1 o más veces (codicioso)” |
| Cuantificador | *? |
“Cuantificador: 0 o más veces (no codicioso / perezoso)” |
| Grupo captura | (abc) |
“Grupo de captura #1: coincide con ‘abc’ literal” |
| Grupo no captura | (?:abc) |
“Grupo sin captura: agrupa sin guardar en $1” |
| Alternancia | a|b |
“Alternancia: coincide con ‘a’ O ‘b’” |
| Lookahead | (?=abc) |
“Lookahead positivo: afirma que sigue ‘abc’ sin consumir” |
| Lookbehind | (?<=abc) |
“Lookbehind positivo: afirma que precede ‘abc’ sin consumir” |
| Propiedad Unicode | \p{L} |
“Propiedad Unicode: cualquier letra en cualquier idioma” |
Atajos de teclado
| Acción | Windows/Linux | Mac |
|---|---|---|
| Ejecutar test | Ctrl + Enter |
Cmd + Enter |
| Limpiar | Ctrl + Shift + X |
Cmd + Shift + X |
| Copiar regex | Ctrl + Shift + C |
Cmd + Shift + C |
| Siguiente preset | Ctrl + → |
Cmd + → |
| Preset anterior | Ctrl + ← |
Cmd + ← |
Prueba el tester ahora
Escribe tu regex, elige flags, pega el texto y ve las coincidencias al instante con explicación detallada.
Prueba tu regex online con resaltado y explicación token a token.
What is a regex tester?
A regex tester (regular expressions) is an interactive tool for writing, testing and debugging text search patterns. It lets you:
- See matches in real time as you type
- Inspect capture groups and their values
- Understand what each token in the pattern does
- Test against multiple test cases at once
- Detect syntax errors before using the regex in production
Anatomy of a Regular Expression
/ ^ [a-z] + \. (com|org) $ / g i m
| | | | | | | | | | |
| | | | | | | | | | └─ flags
| | | | | | | | | └──── sticky (y)
| | | | | | | | └────── unicode (u)
| | | | | | | └───────── dotAll (s)
| | | | | | └──────────── multiline (m)
| | | | | | └───────────── case-insensitive (i)
| | | | | └──────────────────── global (g)
| | | | | └───────────────────── capture group: "com" or "org"
| | | | └──────────────────────────── literal character "."
| | | └──────────────────────────────── quantifier: 1 or more
| | └───────────────────────────────────── character class: lowercase letters
| └────────────────────────────────────────── anchor: start of string
└───────────────────────────────────────────── delimiters (not part of pattern)Flags Available in JavaScript
| Flag | Name | Effect |
|---|---|---|
g |
Global | Finds all matches, not just the first |
i |
Case-insensitive | Ignores upper/lowercase |
m |
Multiline | ^ and $ match start/end of line, not just string |
s |
dotAll | . also matches newline (\n, \r) |
u |
Unicode | Treats pattern as Unicode code (needed for \p{...}, emojis, etc.) |
y |
Sticky | Searches only from lastIndex position (parsing performance) |
Common combination:
gim(global, case-insensitive, multiline) for general searches.
Included Presets
| Preset | Pattern | What it validates |
|---|---|---|
^[^\s@]+@[^\s@]+\.[^\s@]+$ |
Basic email format (simplified RFC 5322) | |
| URL | ^https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)$ |
HTTP/HTTPS URLs |
| IPv4 | `^((25[0-5] | 2[0-4][0-9] |
| DNI/NIE (ES) | ^[0-9]{8}[TRWAGMYFPDXBNJZSQVHLCKE]$ / ^[XYZ][0-9]{7}[TRWAGMYFPDXBNJZSQVHLCKE]$ |
Spanish documents |
| IBAN (ES) | ^ES[0-9]{22}$ |
Spanish IBAN (format only, no check digit validation) |
| Hex Color | `^#([0-9a-fA-F]{3} | [0-9a-fA-F]{6} |
| ISO Date | ^\d{4}-\d{2}-\d{2}$ |
YYYY-MM-DD (format only, doesn’t validate real days) |
| Phone (ES) | `^(+34 | 0034)?[679]\d{8}$` |
Token-by-Token Explainer
The explainer breaks down your pattern and describes each element:
| Type | Example | Generated Explanation |
|---|---|---|
| Anchor | ^ |
“Start of string (or line with m flag)” |
| Anchor | $ |
“End of string (or line with m flag)” |
| Class | [a-z] |
“Character class: any lowercase letter a-z” |
| Negated class | [^0-9] |
“Negated class: any character EXCEPT digits” |
| Escape | \d |
“Shortcut: digit (equivalent to [0-9])” |
| Escape | \. |
“Literal character: dot” |
| Quantifier | + |
“Quantifier: 1 or more times (greedy)” |
| Quantifier | *? |
“Quantifier: 0 or more times (non-greedy / lazy)” |
| Capture group | (abc) |
“Capture group #1: matches ‘abc’ literal” |
| Non-capture group | (?:abc) |
“Non-capture group: groups without saving to $1” |
| Alternation | a|b |
“Alternation: matches ‘a’ OR ‘b’” |
| Lookahead | (?=abc) |
“Positive lookahead: asserts ‘abc’ follows without consuming” |
| Lookbehind | (?<=abc) |
“Positive lookbehind: asserts ‘abc’ precedes without consuming” |
| Unicode property | \p{L} |
“Unicode property: any letter in any language” |
Keyboard Shortcuts
| Action | Windows/Linux | Mac |
|---|---|---|
| Run test | Ctrl + Enter |
Cmd + Enter |
| Clear | Ctrl + Shift + X |
Cmd + Shift + X |
| Copy regex | Ctrl + Shift + C |
Cmd + Shift + C |
| Next preset | Ctrl + → |
Cmd + → |
| Previous preset | Ctrl + ← |
Cmd + ← |
Try the tester now
Write your regex, choose flags, paste the text and see matches instantly with detailed explanation.
Test your regex online with highlighting and token-by-token explanation.