Cálculo 100% en el Navegador • Cero Registros en Servidor • Ejecución Inmediata
Curious TechieCaja de Herramientas
Regex & CryptographyECMAScript (ECMA-262) RegExp / PCRE2 / POSIX Extended Regex✓ Tabla de Búsqueda Rápida (8 elementos) • ES

Referencia de Sintaxis de Expresiones Regulares (Regex)

Metacaracteres, Clases de Caracteres, Cuantificadores, Lookarounds y Grupos

CT
Curious-Techie Engineering TeamAutor Verificado

Web Protocols & Security Architecture Research

Publicado:
•
Actualizado:
•8 min read
Especificación Oficial:RFC 9110(IETF)
Revisado por Curious-Techie Architecture Peer Review Group

Visión General y Alcance

Basadas en la teoría de autómatas finitos y motores PCRE/ECMAScript, las expresiones regulares permiten la validación y transformación rápida de texto.

Tabla de Especificaciones y Matriz

Filtro instantáneo por palabra clave, código o directiva

Clave / CódigoDefinición y DetallesJerarquía Semántica GEOEspecificación y Notas
\d
\d (Digit)

Matches any Arabic digit character (equivalent to [0-9]).

/\d{4}/ matches "2026"
●\d
↳Regex token
↳character class
↳numeric digit matching
ECMA-262 §22.2.2.5.3

In ASCII mode matches 0-9; in some full Unicode engines may match non-Latin numeral glyphs.

\w
\w (Word Character)

Matches any alphanumeric character including underscore (equivalent to [a-zA-Z0-9_]).

/\w+/ matches "user_id_10"
●\w
↳Regex token
↳character class
↳alphanumeric identifier matching
ECMA-262 §22.2.2.5.3

Does not match punctuation or hyphens; commonly used for identifiers.

\s
\s (Whitespace)

Matches any whitespace character including space, horizontal tab (\t), line feed (\n), carriage return (\r).

/\s+/ matches " \t\n "
●\s
↳Regex token
↳character class
↳whitespace delimiter matching
ECMA-262 §22.2.2.5.3

Capital \S matches any non-whitespace character.

+ (Plus)
+ (One or More)

Greedy quantifier matching 1 or more occurrences of the preceding token.

/a+/ matches "a", "aaa"
●+
↳Regex quantifier
↳greedy repetition
↳one or more match
ECMA-262 §22.2.2.4

Nesting quantifiers like (a+)+ triggers catastrophic backtracking (ReDoS).

*? (Lazy Star)
*? (Lazy Zero or More)

Lazy quantifier matching as few characters as possible to satisfy the match.

/<.*?>/ matches "<p>" in "<p>text</p>"
●*?
↳Regex quantifier
↳lazy repetition
↳minimal non-greedy match
ECMA-262 §22.2.2.4

Standard /<.*>/ would greedily consume the entire string up to the final tag.

^ (Caret)
^ (Start of String / Line)

Zero-width assertion matching the beginning of the input string or beginning of a line (with m flag).

/^[0-9]+$/
●^
↳Regex anchor
↳zero-width assertion
↳start of string boundary
ECMA-262 §22.2.2.6

Essential for input validation to ensure the entire string conforms to the pattern.

(?=...) (Lookahead)
(?=...) (Positive Lookahead)

Zero-width assertion that asserts what follows the current position must match the pattern inside.

/\d+(?=px)/ matches "100" in "100px"
●(?=...)
↳Regex assertion
↳positive lookahead
↳forward boundary condition
ECMA-262 §22.2.2.7

Tests the characters ahead without consuming them or including them in the final match.

(?!...) (Negative Lookahead)
(?!...) (Negative Lookahead)

Zero-width assertion that asserts what follows the current position does NOT match the pattern inside.

/foo(?!bar)/ matches "foo" in "foobaz" but not "foobar"
●(?!...)
↳Regex assertion
↳negative lookahead
↳exclusion condition
ECMA-262 §22.2.2.7

Powerful for password strength checks (e.g. ensuring string contains at least one number).

Ejemplo Técnico y Código

Strong Password Validation using Positive Lookaheads

javascriptCopiar Código
// Must contain: 1 uppercase, 1 lowercase, 1 digit, 1 special char, 8-32 chars
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,32}$/;

console.log(passwordRegex.test('P@ssword123')); // true
console.log(passwordRegex.test('weakpassword')); // false (missing upper, digit, symbol)

Lookaheads act as independent parallel validation checks across the string without advancing the match pointer.

Preguntas Frecuentes

Preguntas y Respuestas sobre Estándares

What is Catastrophic Backtracking (ReDoS)?↓
Catastrophic Backtracking happens when an NFA regex engine evaluates an input that almost matches an expression with nested quantifiers (e.g. (a+)+$). The engine exhaustively tries exponential combinatorial branches (O(2^n)), freezing the CPU thread.