Hoja de trucos de Regex
Referencia interactiva de regex con guía de sintaxis buscable. Prueba patrones con coincidencia en vivo. Cubre clases de caracteres, cuantificadores, grupos y banderas.
Showing 39 of 39 entries
Character Classes
10 entries.Any character
Matches any single character except newline (unless s flag is set)
c.tMatches: "cat", "cut", "c3t"\dDigit
Matches any digit character [0-9]
\d+Matches: "42", "007"\DNon-digit
Matches any character that is not a digit
\D+Matches: "abc", "foo!"\wWord character
Matches any alphanumeric character or underscore [A-Za-z0-9_]
\w+Matches: "hello", "foo_42"\WNon-word character
Matches any character that is not a word character
\W+Matches: " ", "!@#"\sWhitespace
Matches any whitespace character: space, tab, newline, carriage return, form feed
\s+Matches: " ", "\t\n"\SNon-whitespace
Matches any character that is not whitespace
\S+Matches: "hello", "word"[abc]Character set
Matches any single character listed inside the brackets
[aeiou]Matches: "a", "e", "i", "o", "u"[^abc]Negated set
Matches any single character NOT listed inside the brackets
[^aeiou]Matches: "b", "c", "d" (not vowels)[a-z]Character range
Matches any character in the specified Unicode range. Combine ranges: [a-zA-Z0-9]
[a-z]+Matches: "hello", "world"Anchors
4 entries^Start of string
Matches the position at the start of the string (or line with m flag)
^HelloMatches: "Hello world" (start only)$End of string
Matches the position at the end of the string (or line with m flag)
world$Matches: "Hello world" (end only)\bWord boundary
Matches the position between a word character and a non-word character
\bcat\bMatches: "cat" but not "catfish"\BNon-word boundary
Matches any position that is not a word boundary
\Bcat\BMatches: "concatenate" (mid-word)Quantifiers
8 entries*Zero or more (greedy)
Matches the preceding element zero or more times, as many as possible
ab*cMatches: "ac", "abc", "abbc"+One or more (greedy)
Matches the preceding element one or more times, as many as possible
ab+cMatches: "abc", "abbc" (not "ac")?Zero or one
Matches the preceding element zero or one time (makes it optional)
colou?rMatches: "color", "colour"{n}Exactly n
Matches the preceding element exactly n times
\d{4}Matches: "2024", "1234"{n,}n or more
Matches the preceding element n or more times
\d{2,}Matches: "12", "999", "1000"{n,m}Between n and m
Matches the preceding element between n and m times (inclusive)
\d{2,4}Matches: "12", "123", "1234"*?Zero or more (lazy)
Matches the preceding element zero or more times, as few as possible
<.+?>Matches: "<b>" in "<b>bold</b>"+?One or more (lazy)
Matches the preceding element one or more times, as few as possible
"[^"]+?"Matches: Shortest quoted stringGroups
6 entries(abc)Capturing group
Groups the expression and captures the matched text. Accessible as \1, \2, or match[1]
(\d{4})Matches: Captures year in "2024-01-15"(?:abc)Non-capturing group
Groups the expression without creating a capture. Use to apply quantifiers without capturing
(?:ab)+Matches: "ab", "abab", "ababab"(?=abc)Positive lookahead
Asserts that what follows the current position matches the pattern (zero-width)
\d+(?= USD)Matches: "100" in "100 USD"(?!abc)Negative lookahead
Asserts that what follows does NOT match the pattern (zero-width)
\d+(?! USD)Matches: "42" in "42 EUR"(?<=abc)Positive lookbehind
Asserts that what precedes the current position matches the pattern (zero-width)
(?<=\$)\d+Matches: "100" in "$100"(?<!abc)Negative lookbehind
Asserts that what precedes does NOT match the pattern (zero-width)
(?<!\$)\d+Matches: "42" but not "$42"Flags
6 entriesgGlobal
Find all matches rather than stopping after the first match
/\d+/gMatches: All numbers in a stringiIgnore case
Makes the pattern case-insensitive
/hello/iMatches: "hello", "HELLO", "Hello"mMultiline
Makes ^ match the start of each line and $ match the end of each line
/^\w+/mMatches: First word of each linesDotAll
Makes . match any character including newline characters
/a.b/sMatches: "a\nb" across newlinesuUnicode
Enables full Unicode matching; required for \p{...} property escapes and 4-byte Unicode code points
/\p{L}+/uMatches: Any Unicode letterySticky
Matches only from the position indicated by lastIndex; does not advance past it
/\d+/yMatches: Only at exact lastIndex positionSpecial
5 entries|Alternation
Matches either the expression before or after the pipe. Acts like OR
cat|dogMatches: "cat" or "dog"\1Backreference
Matches the same text that was matched by capturing group 1. \2 for group 2, etc.
(\w+)\s\1Matches: "the the", "ha ha"\nNewline
Matches a newline character (line feed, LF)
\r?\nMatches: Unix or Windows line endings\tTab
Matches a horizontal tab character
\t+Matches: Tab-indented lines\\Literal backslash
Matches a literal backslash character. Backslash must be escaped as \\
C:\\\w+Matches: "C:\Users" in file pathsQuick Test
— paste a pattern and see matches highlightedCómo usar Hoja de trucos de Regex
- 1Examina sintaxis de regex por categoría.
- 2Busca patrones o conceptos específicos.
- 3Prueba tu regex con el coincidente en vivo.
- 4Copia cualquier patrón para usar en tu código.
Analytics pensado para fundadores.
- Seguimiento de visitantes en tiempo real
- Privacidad primero, sin aviso de cookies
- Configurado en dos minutos