Email Address

Contact
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$

Matches standard email format, supports international domains

Test Examples: ✓ test@example.com ✗ test@.com

Phone Number

Contact
^1[3-9]\d{9}$

Matches Chinese mainland phone numbers

Test Examples: ✓ 13812345678 ✗ 12812345678

ID Card

Identity
^\d{17}[\dXx]$

Matches 18-digit ID card numbers, supports X ending

Test Examples: ✓ 110101199001011234 ✗ 11010119900101123

IP Address

Network
^(?:(?: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]?)$

Matches IPv4 address format

Test Examples: ✓ 192.168.1.1 ✗ 256.1.1.1

URL Link

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

Matches HTTP/HTTPS links

Test Examples: ✓ https://www.example.com ✗ www.example

Date Format

Format
^\d{4}-\d{2}-\d{2}$

Matches YYYY-MM-DD format date

Test Examples: ✓ 2025-10-21 ✗ 2025-10-1

Time Format

Format
^([01]?[0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]$

Matches HH:MM:SS format time

Test Examples: ✓ 23:59:59 ✗ 24:00:00

Chinese Characters

Text
[\u4e00-\u9fa5]

Matches Chinese characters

Test Examples: ✓ 你好世界 ✗ hello world

Numbers and Letters

Text
^[a-zA-Z0-9]+$

Matches strings containing only numbers and letters

Test Examples: ✓ abc123 ✗ abc-123

Password Rule

Format
^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d@$!%*#?&]{8,}$

Requires at least eight characters with letters and numbers.

Test Examples: Valid: pass1234 Invalid: password

Username

Text
^[a-zA-Z0-9_]{3,20}$

Matches 3-20 character usernames with letters, numbers, and underscores.

Test Examples: Valid: user_2026 Invalid: ab

Hex Color

Format
^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$

Matches CSS hex color values such as #fff or #1a73e8.

Test Examples: Valid: #1a73e8 Invalid: #12zz99

UUID

Identity
^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$

Matches common UUID versions 1-5 with standard hyphen groups.

Test Examples: Valid: 550e8400-e29b-41d4-a716-446655440000 Invalid: 550e8400

URL Slug

Text
^[a-z0-9]+(?:-[a-z0-9]+)*$

Matches lowercase URL slugs made from words separated by hyphens.

Test Examples: Valid: regex-examples-guide Invalid: Regex Examples

Domain Name

Network
^(?!-)(?:[a-zA-Z0-9-]{1,63}\.)+[a-zA-Z]{2,}$

Matches simple domain names with one or more labels and a TLD.

Test Examples: Valid: www.example.com Invalid: -example.com

File Extension

Format
^.+\.(jpg|jpeg|png|gif|webp|pdf)$

Matches filenames with common image or PDF extensions.

Test Examples: Valid: report.pdf Invalid: report.exe

How To Choose A Regex Example

Start with the closest template, then adjust it for your input format. Some examples are strict full-value validators, while others are better for finding text inside a longer document. Anchors such as `^` and `$` mean the entire string must match; removing them turns many validators into search patterns.

Pay attention to the regex engine used by your project. JavaScript, Python, Java, PHP, and database engines support many of the same basics but differ around Unicode classes, lookbehind, escaping, and named groups. Always test a template with real valid and invalid examples before using it in production.

JavaScript Regex Flags

Common JavaScript flags include `g` for global matching, `i` for case-insensitive matching, and `m` for multiline anchors. These flags can change the result even when the pattern text is unchanged, so test them deliberately in the Regex Tester.

Regex Examples FAQ

Can I copy these regex examples directly? Yes, but treat them as starting points. Adjust them for your exact rules and test them with edge cases.

Why are some examples strict? Validators often use anchors to require a full-string match. Search patterns are usually more flexible and may omit anchors.

Where should I test an example? Copy it into the Regex Tester or check syntax in the Regex Checker before using it.