メインコンテンツへスキップ
kitlocal.dev

正規表現 (Regex) チートシート

ローカルで実行

100% ブラウザ内で処理されます。入力や出力が端末の外に送信されることはありません。

インタラクティブなライブマッチャーラボ付きの正規表現構文と再利用可能なレシピ集:アンカー、文字クラス、量指定子、先読み・後読み、フラグ (ES2024)。

動作の仕組み

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.

サバイバルキット

最初に覚えるべき最小限のコマンド。

41 件のコマンド

キーボードショートカット/検索にフォーカスJK選択を移動C選択項目をコピーF選択項目をブックマークEsc検索をクリア

Characters & character classes

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

公式ドキュメント: Character classes
  • 基本

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

    \d  \w  \s

    使いどころ

    Core shorthand character classes used in almost every pattern.

    コマンドの内訳

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

    実例

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

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

    実行結果

    ["2026-11-15"]

    関連項目

Anchors & boundaries

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

公式ドキュメント: Assertions

Quantifiers & laziness

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

公式ドキュメント: Quantifiers

Groups, alternation & backreferences

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

公式ドキュメント: Groups and backreferences

Lookaheads, lookbehinds & flags

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

公式ドキュメント: Assertions & flags

KitLocalツールで試す

用語集
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.

2026/11/15 に検証済み · ES2024 RegExp で検証済み

出典: MDN Regular Expressions Guide · MDN RegExp Reference

山括弧内の内容は実際の値に置き換えてください。コマンドは公式ドキュメントに基づいており、実例は記載されたバージョンで実行確認されています。