Regex Cheatsheet

Regular Expression pattern collection and quick reference guide

Common Patterns

Email
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Example: user@example.com
Phone Number
^01[0-9]-\d{3,4}-\d{4}$
Example: 010-1234-5678
URL
^https?:\/\/[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(\/[^\s]*)?$
Example: https://example.com
Date (YYYY-MM-DD)
^\d{4}-\d{2}-\d{2}$
Example: 2024-01-15
Time (HH:MM:SS)
^\d{2}:\d{2}(:\d{2})?$
Example: 13:45:30
Password (8+ chars, letters+numbers)
^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,}$
Example: Pass1234
Korean ID Number
^\d{6}-[1-4]\d{6}$
Example: 900101-1234567
Business Registration Number
^\d{3}-\d{2}-\d{5}$
Example: 123-45-67890
Postal Code
^\d{5,6}$
Example: 06234
Number with Commas
^[0-9]{1,3}(,[0-9]{3})*$
Example: 1,234,567
Hex Color Code
^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
Example: #FF5733
IPv4 Address
^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$
Example: 192.168.1.1

Metacharacters

Any character (except newline)
.
Example: a.c matches "abc", "a1c"
Digit (0-9)
\d
Example: \d\d matches "12"
Non-digit
\D
Example: \D matches "a", " "
Word character (a-z, A-Z, 0-9, _)
\w
Example: \w+ matches "Hello123"
Non-word character
\W
Example: \W matches " ", "!"
Whitespace (space, tab, newline)
\s
Example: \s+ matches " "
Non-whitespace
\S
Example: \S+ matches "Hello"
Tab character
\t
Example: a\tb matches "a b"
Newline character
\n
Example: line1\nline2

Quantifiers

Zero or more times
*
Example: ab*c matches "ac", "abc", "abbc"
One or more times
+
Example: ab+c matches "abc", "abbc"
Zero or one time
?
Example: ab?c matches "ac", "abc"
Exactly n times
{n}
Example: a{3} matches "aaa"
n or more times
{n,}
Example: a{2,} matches "aa", "aaa"
Between n and m times
{n,m}
Example: a{2,4} matches "aa", "aaa", "aaaa"
Lazy match (zero or more)
*?
Example: <.*?> matches "<a>"
Lazy match (one or more)
+?
Example: <.+?> matches "<a>"

Anchors

Start of string
^
Example: ^Hello matches "Hello world"
End of string
$
Example: world$ matches "Hello world"
Word boundary
\b
Example: \bcat\b matches "cat" in "the cat"
Non-word boundary
\B
Example: \Bcat\B matches "cat" in "locate"

Groups & Capturing

Capturing group
(abc)
Example: (\d+)-(\d+) captures "123-456"
Non-capturing group
(?:abc)
Example: (?:http|https)://example.com
OR (a or b)
a|b
Example: cat|dog matches "cat" or "dog"
Character class (a, b, or c)
[abc]
Example: [aeiou] matches vowels
Negated class (not a, b, or c)
[^abc]
Example: [^0-9] matches non-digits
Range (a to z)
[a-z]
Example: [a-zA-Z] matches all letters
Positive lookahead
(?=...)
Example: \d(?=px) matches "5" in "5px"
Negative lookahead
(?!...)
Example: \d(?!px) matches "5" not in "5px"

Korean-specific

Korean characters (가-힣)
[가-힣]
Example: [가-힣]+ matches "안녕하세요"
Korean consonants
[ㄱ-ㅎ]
Example: [ㄱ-ㅎ] matches "ㄱ", "ㄴ"
Korean vowels
[ㅏ-ㅣ]
Example: [ㅏ-ㅣ] matches "ㅏ", "ㅓ"
Korean name (2-4 chars)
^[가-힣]{2,4}$
Example: 홍길동, 김철수
Korean phone (area code)
^0(2|3[1-3]|4[1-4]|5[1-5]|6[1-4])-\d{3,4}-\d{4}$
Example: 02-1234-5678
New postal code (5 digits)
^\d{5}$
Example: 06234

How to Use

  1. Browse regular expression patterns organized by category
  2. Hover over a pattern and click the 'Copy' button
  3. Paste the copied pattern into your code or text editor
  4. Use the search box to quickly find specific patterns

Frequently Asked Questions

What is Regex?

Regular Expression (Regex) is a powerful tool for searching, extracting, and replacing strings with specific patterns. It's widely used in programming, data validation, and text processing.

How do I use it?

Click on the desired pattern to copy it, then use it in your programming language or text editor. Most programming languages like JavaScript, Python, and Java support regular expressions.

How do I test patterns?

Enter text in the test area below, copy the desired pattern, and test it in a regex tester tool.

정규식(Regex) 핵심 가이드

정규식 핵심 문법 정리

정규식은 메타문자, 수량자, 앵커, 그룹이라는 네 가지 핵심 요소로 구성됩니다. 메타문자는 특정 문자 집합을 간결하게 표현하고, 수량자(*, +, ?, \{n,m\})는 반복 횟수를 제어합니다. 앵커(^, $)는 매칭 위치를 제한하며, 그룹은 부분 패턴을 캡처하거나 묶어서 반복·대체에 활용합니다. 이 요소들을 조합하면 이메일, URL, 전화번호 등 복잡한 형식 검증 패턴을 간결하게 표현할 수 있습니다.

실무 패턴 모음

실무에서 가장 자주 사용되는 정규식 패턴으로는 이메일 검증, 한국 휴대폰 번호, URL 검증, 날짜 형식 등이 있습니다. 비밀번호 복잡성 검사에는 전방탐색(lookahead)을 활용하여 영문·숫자·특수문자 조건을 동시에 검증할 수 있습니다. 한국어 처리 시에는 [가-힣] 범위를 사용하여 한글 문자를 정확하게 매칭합니다. 위 치트시트에서 각 패턴의 상세 문법과 예시를 확인할 수 있습니다.

언어별 정규식 차이

정규식의 기본 문법은 대부분의 프로그래밍 언어에서 공통이지만 세부 동작에 차이가 있습니다. JavaScript는 /pattern/flags 리터럴 문법을 사용하며 유니코드 지원을 위해 u 플래그가 필요합니다. Python의 re 모듈은 raw string 표기로 백슬래시 처리를 단순화합니다. Java는 Pattern.compile()로 정규식을 컴파일하며 이중 백슬래시를 사용합니다. 각 언어의 전방탐색·후방탐색 지원 여부와 플래그 의미를 확인하고 사용하는 것이 중요합니다.

This calculator is provided for informational purposes only.

Results are estimates and may differ from actual amounts.

© 2025 calculkorea. All rights reserved.

Link copied!