Ir para o conteúdo principal
kitlocal.dev

Cheatsheet de Regex

Roda localmente

100% processado no seu navegador. Entradas e saídas nunca saem do seu dispositivo.

Sintaxe de expressões regulares e receitas reutilizáveis com laboratórios interativos ao vivo: âncoras, classes de caracteres, quantificadores, lookarounds e flags (ES2024).

Como funciona

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 de sobrevivência

Os principais comandos para aprender primeiro.

41 comandos

Atalhos de teclado/Focar buscaJKMover seleçãoCCopiar selecionadoFFavoritar selecionadoEscLimpar busca

Characters & character classes

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

Documentação oficial: Character classes
  • Essencial

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

    \d  \w  \s

    Quando usar

    Core shorthand character classes used in almost every pattern.

    Detalhamento

    \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)

    Exemplo

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

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

    Resultado

    ["2026-11-15"]

    Veja também

Anchors & boundaries

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

Documentação oficial: Assertions

Quantifiers & laziness

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

Documentação oficial: Quantifiers

Groups, alternation & backreferences

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

Documentação oficial: Groups and backreferences

Lookaheads, lookbehinds & flags

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

Documentação oficial: Assertions & flags

Experimente em uma ferramenta do KitLocal

Glossário
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.

Verificado em 15 de nov. de 2026 · Verificado na versão ES2024 RegExp

Fontes: MDN Regular Expressions Guide · MDN RegExp Reference

Substitua qualquer item entre colchetes angulares pelos seus próprios valores. Os comandos vêm da documentação oficial e os exemplos foram executados na versão indicada.