>_FoxiRef
>_/cheatsheet/regex
Regex

Regex Cheatsheet

Quick reference for regular expression syntax

#Anchors

PatternDescriptionExample
^Start of string^Hello
$End of stringworld$
\bWord boundary\bword\b
\BNot word boundary\Bword\B

#Character Classes

PatternDescriptionExample
.Any character except newline-
\dDigit [0-9]-
\DNot a digit-
\wWord character-
\WNot a word character-
\sWhitespace-
\SNot whitespace-
[abc]a, b, or c-
[^abc]Not a, b, or c-
[a-z]a to z-

#Quantifiers

PatternDescriptionExample
*0 or morea*
+1 or morea+
?0 or 1a?
{n}Exactly na{3}
{n,}n or morea{2,}
{n,m}Between n and ma{2,4}
*?Lazy 0 or more-
+?Lazy 1 or more-

#Groups & References

PatternDescriptionExample
(abc)Capturing group-
(?:abc)Non-capturing group-
(?<name>abc)Named group-
\1Backreference-
(a|b)a or b-

#Lookaround

PatternDescriptionExample
(?=abc)Positive lookahead-
(?!abc)Negative lookahead-
(?<=abc)Positive lookbehind-
(?<!abc)Negative lookbehind-

#Flags

PatternDescriptionExample
gGlobal search-
iCase insensitive-
mMultiline mode-
sDotall mode-
uUnicode mode-

#Common Patterns

PatternDescriptionExample
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$Email-
^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

이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.

Regex Cheatsheet - Regular Expressions | Foxi Dev Reference