#Anchors
| Pattern | Description | Example | |
|---|---|---|---|
^ | Start of string | ^Hello | |
$ | End of string | world$ | |
\b | Word boundary | \bword\b | |
\B | Not word boundary | \Bword\B |
#Character Classes
| Pattern | Description | Example | |
|---|---|---|---|
. | Any character except newline | - | |
\d | Digit [0-9] | - | |
\D | Not a digit | - | |
\w | Word character | - | |
\W | Not a word character | - | |
\s | Whitespace | - | |
\S | Not whitespace | - | |
[abc] | a, b, or c | - | |
[^abc] | Not a, b, or c | - | |
[a-z] | a to z | - |
#Quantifiers
| Pattern | Description | Example | |
|---|---|---|---|
* | 0 or more | a* | |
+ | 1 or more | a+ | |
? | 0 or 1 | a? | |
{n} | Exactly n | a{3} | |
{n,} | n or more | a{2,} | |
{n,m} | Between n and m | a{2,4} | |
*? | Lazy 0 or more | - | |
+? | Lazy 1 or more | - |
#Groups & References
| Pattern | Description | Example | |
|---|---|---|---|
(abc) | Capturing group | - | |
(?:abc) | Non-capturing group | - | |
(?<name>abc) | Named group | - | |
\1 | Backreference | - | |
(a|b) | a or b | - |
#Lookaround
| Pattern | Description | Example | |
|---|---|---|---|
(?=abc) | Positive lookahead | - | |
(?!abc) | Negative lookahead | - | |
(?<=abc) | Positive lookbehind | - | |
(?<!abc) | Negative lookbehind | - |
#Flags
| Pattern | Description | Example | |
|---|---|---|---|
g | Global search | - | |
i | Case insensitive | - | |
m | Multiline mode | - | |
s | Dotall mode | - | |
u | Unicode mode | - |
#Common Patterns
| Pattern | Description | Example | |
|---|---|---|---|
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ | - | ||
^https?:\/\/[\S]+$ | URL | - | |
^\d{3}-\d{4}-\d{4}$ | Phone (Korea) | - | |
^\d{4}-\d{2}-\d{2}$ | Date (YYYY-MM-DD) | - | |
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$ | Hex color | - |
#Frequently Asked Questions
이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.