| 문법 | 설명 |
|---|---|
. | Any character except newline |
\d | Digit [0-9] |
\D | Non-digit [^0-9] |
\w | Word char [a-zA-Z0-9_] |
\W | Non-word character |
\s | Whitespace (space, tab, newline) |
\S | Non-whitespace |
[abc] | One of a, b, or c |
[^abc] | Not a, b, or c |
[a-z] | Character in range a–z |
[a-zA-Z] | Letter (any case) |
\p{L} | Any Unicode letter (u flag) |
| 문법 | 설명 |
|---|---|
^ | Start of string (or line with m flag) |
$ | End of string (or line with m flag) |
\b | Word boundary |
\B | Non-word boundary |
\A | Start of string (Python/Java) |
\Z | End of string (Python/Java) |
| 문법 | 설명 |
|---|---|
* | 0 or more (greedy) |
+ | 1 or more (greedy) |
? | 0 or 1 (optional) |
{n} | Exactly n times |
{n,} | n or more times |
{n,m} | Between n and m times |
*? | 0 or more (lazy) |
+? | 1 or more (lazy) |
?? | 0 or 1 (lazy) |
| 문법 | 설명 |
|---|---|
(abc) | Capturing group |
(?:abc) | Non-capturing group |
(?<name>abc) | Named capturing group |
\1 | Backreference to group 1 |
\k<name> | Named backreference |
(?|...) | Branch reset group (PCRE) |
| 문법 | 설명 |
|---|---|
(?=abc) | Positive lookahead — must be followed by abc |
(?!abc) | Negative lookahead — must NOT be followed by abc |
(?<=abc) | Positive lookbehind — must be preceded by abc |
(?<!abc) | Negative lookbehind — must NOT be preceded by abc |
| 플래그 | 이름 | 설명 |
|---|---|---|
g | Global | Find all matches, not just the first |
i | Case-insensitive | Match regardless of case (A = a) |
m | Multiline | ^ and $ match start/end of each line |
s | Dotall | . matches newline characters too |
u | Unicode | Enable full Unicode support (\p{} classes) |
y | Sticky | Match only at lastIndex position (JS) |
x | Extended | Allow whitespace + comments in pattern (Python/PHP) |
| 패턴 | Regex | 테스트 |
|---|---|---|
[a-zA-Z0-9._%+\-]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,} | Regex 테스터에서 시도 → | |
| URL | https?:\/\/[\w\-]+(\.[\w\-]+)+[\w\-._~:/?#[\]@!$&'()*+,;=%]* | Regex 테스터에서 시도 → |
| IPv4 Address | \b(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\b | Regex 테스터에서 시도 → |
| Phone (US) | \+?1?[\s.-]?\(?\d{3}\)?[\s.-]?\d{3}[\s.-]?\d{4} | Regex 테스터에서 시도 → |
| Date (YYYY-MM-DD) | \d{4}-(?:0[1-9]|1[0-2])-(?:0[1-9]|[12]\d|3[01]) | Regex 테스터에서 시도 → |
| Time (HH:MM) | (?:[01]\d|2[0-3]):[0-5]\d | Regex 테스터에서 시도 → |
| UUID | [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12} | Regex 테스터에서 시도 → |
| Hex Color | #(?:[0-9a-fA-F]{3}){1,2}\b | Regex 테스터에서 시도 → |
| Slug | [a-z0-9]+(?:-[a-z0-9]+)* | Regex 테스터에서 시도 → |
| ZIP Code (US) | \d{5}(?:-\d{4})? | Regex 테스터에서 시도 → |
| Credit Card | (?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13}) | Regex 테스터에서 시도 → |
| HTML Tag | <([a-zA-Z][a-zA-Z0-9]*)(?:\s[^>]*)?\/?>.*?<\/\1> | Regex 테스터에서 시도 → |
| Markdown Bold | \*\*([^*]+)\*\* | Regex 테스터에서 시도 → |
| JWT Token | [A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+ | Regex 테스터에서 시도 → |
| Semver | \bv?(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[\w.]+)?\b | Regex 테스터에서 시도 → |
| GitHub Username | (?<=github\.com\/)([a-zA-Z0-9](?:[a-zA-Z0-9-]{0,37}[a-zA-Z0-9])?) | Regex 테스터에서 시도 → |
| Positive Integer | ^[1-9]\d*$ | Regex 테스터에서 시도 → |
| Float / Decimal | -?\d+(?:\.\d+)? | Regex 테스터에서 시도 → |
| Blank Lines | ^\s*$ | Regex 테스터에서 시도 → |
| Duplicate Words | \b(\w+)\s+\1\b | Regex 테스터에서 시도 → |
정규 표현식은 검색 패턴을 정의하는 문자 시퀀스입니다. 문자열 검색, 매칭 및 조작에 사용됩니다. Regex는 JavaScript, Python, Java, PHP, Go 및 대부분의 현대 프로그래밍 언어에서 기본적으로 지원됩니다.
탐욕적 수량자(*, +, {n,m})는 가능한 한 많은 문자와 일치합니다. 게으른 수량자(*?, +?, {n,m}?)는 가능한 한 적은 문자와 일치합니다.
룩어헤드(?=...)와 룩비하인드(?<=...)는 문자를 소비하지 않고 패턴을 확인하는 너비가 0인 어서션입니다. 양의 룩어헤드(?=foo)는 'foo'가 뒤따름을 단언합니다.
핵심 구문(문자 클래스, 수량자, 앵커)은 대부분의 언어에서 일관됩니다. 그러나 룩비하인드, 명명된 그룹, 특정 플래그와 같은 기능은 엔진에 따라 다릅니다.