Vai al contenuto principale
kitlocal.dev

Cheatsheet Regex

Esecuzione locale

Elaborazione al 100% nel tuo browser. Input e output non lasciano mai il tuo dispositivo.

Sintassi delle espressioni regolari e ricette riutilizzabili con laboratori interattivi dal vivo: ancore, classi di caratteri, quantificatori, lookaround e flag (ES2024).

Come funziona

A regex engine scans left-to-right trying to satisfy your pattern at each position. Quantifiers (*, +, {n,m}) are greedy by default (consuming as much as possible before backtracking); append `?` to make them lazy, and anchor with `^`/`$` or `\b` when you need exact boundaries.

Kit di sopravvivenza

I pochi comandi da imparare per primi.

41 comandi

Scorciatoie da tastiera/Attiva ricercaJKSposta selezioneCCopia selezionatoFAggiungi selezionato ai segnalibriEscCancella ricerca

Characters & character classes

Match single characters by category (`\d`, `\w`, `\s`) or explicit sets (`[a-f0-9]`). Uppercase shorthands invert the match.

Documentazione ufficiale: Character classes
  • Essenziale

    Match a digit, word character ([A-Za-z0-9_]) or whitespace.

    \d  \w  \s

    Quando usarlo

    Core shorthand character classes used in almost every pattern.

    Dettaglio

    \d
    ASCII digit [0-9] (uppercase \D = non-digit)
    \w
    alphanumeric + underscore (uppercase \W = non-word)
    \s
    space, tab or newline (uppercase \S = non-whitespace)

    Esempio

    Matches dates inside `"release 2026-11-15"`.

    \d{4}-\d{2}-\d{2}

    Risultato

    ["2026-11-15"]

    Vedi anche

Anchors & boundaries

Anchors match positions (start/end of string, line or word) rather than consuming characters.

Documentazione ufficiale: Assertions

Quantifiers & laziness

Control how many times the preceding token repeats. Add `?` after any quantifier to match as few times as possible.

Documentazione ufficiale: Quantifiers

Groups, alternation & backreferences

Parentheses group sub-expressions for quantifiers/alternation and capture text for extraction or backreferences.

Documentazione ufficiale: Groups and backreferences

Lookaheads, lookbehinds & flags

Check what appears ahead or behind the current position without making it part of the matched text.

Documentazione ufficiale: Assertions & flags

Provalo in uno strumento di KitLocal

Glossario
Greedy vs Lazy
`.*` grabs to the last possible match; `.*?` stops at the earliest match.
Lookaround
Zero-width assertion (`(?=...)`, `(?!...)`, `(?<=...)`) that checks surrounding text without consuming characters.
Backtracking
When a quantifier gives up matched characters so later tokens can match; nested `*`/`+` can cause ReDoS.
Zero-width
Tokens like `^`, `$`, `\b` and lookarounds that match a position rather than characters.

Verificato il 15 nov 2026 · Verificato sulla versione ES2024 RegExp

Fonti: MDN Regular Expressions Guide · MDN RegExp Reference

Sostituisci gli elementi tra parentesi angolari con i tuoi valori. I comandi provengono dalla documentazione ufficiale e gli esempi sono stati eseguiti sulla versione indicata.