Skip to main content

Regex Library

A collection of commonly used regular expression patterns. Search and copy to use right away!

Email

Basic Email

기본 이메일 형식

^[\w\.-]+@[\w\.-]+\.\w+$
Example:user@example.com

RFC 5322 Email

RFC 5322 표준 이메일

^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$
Example:user.name+tag@example.co.kr

URL

HTTP/HTTPS URL

HTTP/HTTPS URL

^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$
Example:https://www.example.com/path?query=value

Domain Name

도메인 이름

^(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$
Example:example.com

Phone

Korean Phone

한국 휴대폰 번호

^01[0-9]-?[0-9]{3,4}-?[0-9]{4}$
Example:010-1234-5678

US Phone

미국 전화번호

^\(?([0-9]{3})\)?[-. ]?([0-9]{3})[-. ]?([0-9]{4})$
Example:(123) 456-7890

International Phone

E.164 국제 전화번호

^\+?[1-9]\d{1,14}$
Example:+821012345678

Date & Time

Date (YYYY-MM-DD)

ISO 8601 날짜 형식

^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01])$
Example:2024-01-15

Time (HH:MM:SS)

24시간 시간 형식

^([01]\d|2[0-3]):([0-5]\d):([0-5]\d)$
Example:14:30:45

Date (DD/MM/YYYY)

DD/MM/YYYY 형식

^(0[1-9]|[12]\d|3[01])\/(0[1-9]|1[0-2])\/\d{4}$
Example:15/01/2024

Numbers

Integer

정수

^-?\d+$
Example:-123

Decimal

소수

^-?\d*\.?\d+$
Example:123.45

Positive Integer

양의 정수

^[1-9]\d*$
Example:123

Credit Card

신용카드 번호 (Visa, MasterCard, Amex)

^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|3[47][0-9]{13})$
Example:4111111111111111

Password

Strong Password

최소 8자, 대소문자, 숫자, 특수문자 포함

^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,}$
Example:Abcd1234!

Medium Password

최소 6자, 영문+숫자

^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d]{6,}$
Example:Abcd1234

Code

IPv4 Address

IPv4 주소

^(?:(?: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

IPv6 Address

IPv6 주소

^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$
Example:2001:0db8:85a3:0000:0000:8a2e:0370:7334

Hex Color

HEX 색상 코드

^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$
Example:#FF5733

HTML Tag

HTML 태그

<[^>]+>
Example:<div class="test">

Korean

Hangul Only

한글만

^[가-힣]+$
Example:한글

Korean Name

한국 이름 (2-4자)

^[가-힣]{2,4}$
Example:홍길동

Korean ID (RRN)

주민등록번호

^\d{6}-?[1-4]\d{6}$
Example:901231-1234567

Categories

📧 Email

Regex patterns for email address validation

🌐 URL

Web address and domain validation patterns

📞 Phone

Phone number format patterns for various countries

📅 Date & Time

Date and time format validation patterns

🔢 Numbers

Numbers, integers, decimals, credit card numbers, etc.

🔐 Password

Password strength validation patterns

💻 Code

Code-related patterns like IP addresses, color codes, HTML tags

🇰🇷 Korean

Korean patterns including Hangul, Korean names, resident registration numbers

How to Use

  1. Select Category: Click on the desired category button
  2. Search: Search for the pattern you want in the search bar
  3. Copy: Click the 📋 button to copy the pattern
  4. Test: Click the 🧪 button to test directly in Regex Tester

Usage Examples

Form Validation

const emailRegex = /^[\w\.-]+@[\w\.-]+\.\w+$/;
if (!emailRegex.test(userInput)) {
alert('Invalid email address');
}

Data Extraction

const urlRegex = /https?:\/\/[^\s]+/g;
const urls = text.match(urlRegex);

Data Sanitization

const phoneRegex = /^01[0-9]-?[0-9]{3,4}-?[0-9]{4}$/;
const cleanPhone = phone.replace(/-/g, '');

Regex Tips

Common Metacharacters

  • ^ - Start of string
  • $ - End of string
  • . - Any single character
  • * - 0 or more repetitions
  • + - 1 or more repetitions
  • ? - 0 or 1 occurrence
  • [] - Character class
  • | - OR operator
  • () - Grouping

Flags

  • g - Global search
  • i - Case insensitive
  • m - Multiline mode

Cautions

  • Regex is not perfect - complex validation may require additional logic
  • Be cautious with large texts as it can affect performance
  • Don't rely solely on client-side validation; server-side validation is also necessary

Contributing

If you have more useful regex patterns, please suggest them!