100% 브라우저 메모리 연산 • 서버 로그 수집 제로 • 즉각적인 실행
Curious Techie개발자 툴박스
Regex & CryptographyECMAScript (ECMA-262) RegExp / PCRE2 / POSIX Extended Regex✓ 빠른 조회 매트릭스 표 (8 개 항목) • KO

정규 표현식 (Regex) 문법 치트시트 및 레퍼런스

메타 문자, 수량자, 캡처 그룹, 전방/후방 탐색(Lookaround) 총정리

CT
Curious-Techie Engineering Team검증된 작성자

Web Protocols & Security Architecture Research

발행일:
•
수정일:
•8 min read
공식 기술 규격:RFC 9110(IETF)
검토자: Curious-Techie Architecture Peer Review Group

개요 및 범위

ECMAScript 및 PCRE 표준 엔진에서 구동되는 정규식은 데이터 파싱 및 텍스트 마이닝 작업의 필수적인 프로그래밍 요소입니다.

표준 규격표 및 매트릭스

키워드, 상태 코드 또는 지시문 이름으로 실시간 검색

키 / 코드정의 및 세부사항GEO 시맨틱 계층표준 규격 및 참고
\d
\d (Digit)

Matches any Arabic digit character (equivalent to [0-9]).

/\d{4}/ matches "2026"
●\d
↳Regex token
↳character class
↳numeric digit matching
ECMA-262 §22.2.2.5.3

In ASCII mode matches 0-9; in some full Unicode engines may match non-Latin numeral glyphs.

\w
\w (Word Character)

Matches any alphanumeric character including underscore (equivalent to [a-zA-Z0-9_]).

/\w+/ matches "user_id_10"
●\w
↳Regex token
↳character class
↳alphanumeric identifier matching
ECMA-262 §22.2.2.5.3

Does not match punctuation or hyphens; commonly used for identifiers.

\s
\s (Whitespace)

Matches any whitespace character including space, horizontal tab (\t), line feed (\n), carriage return (\r).

/\s+/ matches " \t\n "
●\s
↳Regex token
↳character class
↳whitespace delimiter matching
ECMA-262 §22.2.2.5.3

Capital \S matches any non-whitespace character.

+ (Plus)
+ (One or More)

Greedy quantifier matching 1 or more occurrences of the preceding token.

/a+/ matches "a", "aaa"
●+
↳Regex quantifier
↳greedy repetition
↳one or more match
ECMA-262 §22.2.2.4

Nesting quantifiers like (a+)+ triggers catastrophic backtracking (ReDoS).

*? (Lazy Star)
*? (Lazy Zero or More)

Lazy quantifier matching as few characters as possible to satisfy the match.

/<.*?>/ matches "<p>" in "<p>text</p>"
●*?
↳Regex quantifier
↳lazy repetition
↳minimal non-greedy match
ECMA-262 §22.2.2.4

Standard /<.*>/ would greedily consume the entire string up to the final tag.

^ (Caret)
^ (Start of String / Line)

Zero-width assertion matching the beginning of the input string or beginning of a line (with m flag).

/^[0-9]+$/
●^
↳Regex anchor
↳zero-width assertion
↳start of string boundary
ECMA-262 §22.2.2.6

Essential for input validation to ensure the entire string conforms to the pattern.

(?=...) (Lookahead)
(?=...) (Positive Lookahead)

Zero-width assertion that asserts what follows the current position must match the pattern inside.

/\d+(?=px)/ matches "100" in "100px"
●(?=...)
↳Regex assertion
↳positive lookahead
↳forward boundary condition
ECMA-262 §22.2.2.7

Tests the characters ahead without consuming them or including them in the final match.

(?!...) (Negative Lookahead)
(?!...) (Negative Lookahead)

Zero-width assertion that asserts what follows the current position does NOT match the pattern inside.

/foo(?!bar)/ matches "foo" in "foobaz" but not "foobar"
●(?!...)
↳Regex assertion
↳negative lookahead
↳exclusion condition
ECMA-262 §22.2.2.7

Powerful for password strength checks (e.g. ensuring string contains at least one number).

기술 예제 및 실행 코드

Strong Password Validation using Positive Lookaheads

javascript코드 복사
// Must contain: 1 uppercase, 1 lowercase, 1 digit, 1 special char, 8-32 chars
const passwordRegex = /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,32}$/;

console.log(passwordRegex.test('P@ssword123')); // true
console.log(passwordRegex.test('weakpassword')); // false (missing upper, digit, symbol)

Lookaheads act as independent parallel validation checks across the string without advancing the match pointer.

자주 묻는 질문 (FAQ)

표준 규격 Q&A

What is Catastrophic Backtracking (ReDoS)?↓
Catastrophic Backtracking happens when an NFA regex engine evaluates an input that almost matches an expression with nested quantifiers (e.g. (a+)+$). The engine exhaustively tries exponential combinatorial branches (O(2^n)), freezing the CPU thread.