본문으로 바로 가기
kitlocal.dev

정규식 (Regex) 치트시트

로컬에서 실행

100% 브라우저에서 처리됩니다. 입력과 출력이 기기 밖으로 나가지 않습니다.

대화형 실시간 매처 실습실이 포함된 정규식 구문 및 재사용 가능한 레시피: 앵커, 문자 클래스, 수량자, 전후방 탐색(lookaround) 및 플래그 (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

꺾쇠괄호 안의 내용을 본인의 값으로 바꾸세요. 명령어는 공식 문서에서 가져왔으며, 예제는 명시된 버전에서 실행되었습니다.