.*
Guida Rapida

Guida Rapida Regex

Un riferimento completo per la sintassi delle espressioni regolari da consultare quotidianamente.

Classi di Caratteri

SintassiDescrizione
.Any character except newline
\dAny digit (0-9)
\DAny non-digit
\wWord character (letter, digit, underscore)
\WNon-word character
\sAny whitespace (space, tab, newline)
\SAny non-whitespace
[abc]Any one of a, b, or c
[^abc]Any character except a, b, or c
[a-z]Any character in range a to z
[0-9]Any digit (same as \d)

Quantificatori

SintassiDescrizione
*Match 0 or more times (greedy)
+Match 1 or more times (greedy)
?Match 0 or 1 time (optional)
{n}Match exactly n times
{n,}Match n or more times
{n,m}Match between n and m times
*?Match 0 or more times (lazy)
+?Match 1 or more times (lazy)
??Match 0 or 1 time (lazy)

Ancore e Confini

SintassiDescrizione
^Start of string (or line with m flag)
$End of string (or line with m flag)
\bWord boundary
\BNon-word boundary

Gruppi e Riferimenti Indietro

SintassiDescrizione
(abc)Capturing group
(?:abc)Non-capturing group
(?<name>abc)Named capturing group
\1Backreference to group 1
\k<name>Named backreference
(a|b)Alternation (OR)

Lookahead e Lookbehind

SintassiDescrizione
(?=abc)Positive lookahead — followed by abc
(?!abc)Negative lookahead — NOT followed by abc
(?<=abc)Positive lookbehind — preceded by abc
(?<!abc)Negative lookbehind — NOT preceded by abc

Flag

SintassiDescrizione
gGlobal — find all matches
iCase-insensitive
mMultiline — ^ and $ match line boundaries
sDotall — . matches newlines too
uUnicode mode
vUnicode sets (extended)
dGenerate indices for matches
ySticky — match from lastIndex only

Caratteri Speciali

SintassiDescrizione
\nNewline
\rCarriage return
\tTab
\0Null character
\\Literal backslash
\.Literal dot
\[Literal opening bracket