Miễn phíDùng thử với tài khoản miễn phí

Trình tạo biểu thức chính quy

Tạo biểu thức chính quy một cách dễ dàng.

Bắt đầu

Có trong các gói trả phí. Tài khoản miễn phí được dùng thử một lần. Mọi thứ bạn nhập ở đây đều được lưu lại cho bạn.

Ví dụ

validate an email address

Email Address Validation Regex

Basic Pattern
regex
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$  
Explanation
PartDescription
^Start of string
[a-zA-Z0-9._%+-]+Local part: letters, digits, dots, underscores, percent, plus, hyphen (one or more)
@Literal @ symbol
[a-zA-Z0-9.-]+Domain name: letters, digits, dots, hyphens
\.Literal dot before TLD
[a-zA-Z]{2,}Top-level domain: at least 2 letters (e.g., com, org, io)
$End of string
Example Matches

✅ Valid:

❌ Invalid:

Stricter Version (RFC 5322-lite)
regex
^(?!.*\.\.)[a-zA-Z0-9](?:[a-zA-Z0-9._%+-]*[a-zA-Z0-9_%+-])?@[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?)+\.[a-zA-Z]{2,}$  

This prevents consecutive dots, leading/trailing dots, and edge cases like [email protected].

Usage Example (JavaScript)
javascript
const emailRegex = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;  
  
console.log(emailRegex.test("[email protected]")); // true  
console.log(emailRegex.test("invalid@"));         // false  

Note: Fully RFC 5322–compliant email validation is extremely complex. For production use, the simple pattern above plus a confirmation email is the recommended approach.

Kết quả thực tế từ công cụ này. Kết quả của bạn sẽ dựa trên nội dung bạn nhập.

  • Không cần thẻ tín dụng
  • Sử dụng các mô hình AI hàng đầu
  • Hơn 3,4 triệu người đã đăng ký

Được tin dùng bởi các nhóm tại những công ty và trường đại học như

  • Honeywell
  • Deloitte
  • Zoho

Bắt đầu thật dễ dàng

Bắt đầu
  1. 01

    Tạo tài khoản miễn phí

    Chỉ mất vài giây. Không cần thẻ tín dụng.

  2. 02

    Điền vài thông tin

    Cho công cụ biết bạn cần gì. Trả lời ngắn gọn cũng được.

    • Bạn muốn tạo loại biểu thức chính quy nào?
    • Kiểu biểu thức chính quy (tùy chọn)
  3. 03

    Tạo và chỉnh sửa

    Nhấn Tạo, rồi sao chép, chỉnh sửa hoặc lưu kết quả.

Văn bản được tạo bởi AI

  • ĐẦU VÀO

    a valid email

    ĐẦU RA

    Valid Email Regular Expression

    regex
    ^[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])?)+$  
    Explanation
    PartDescription
    ^Start of string
    [a-zA-Z0-9.!#$%&'*+/=?^_{|}~-]+`Local part: letters, digits, and common special characters
    @Literal @ symbol
    [a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?Domain name: must start/end with alphanumeric, max 63 chars per label
    (?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+One or more dot-separated domain labels
    $End of string
    Example Matches

    ✅ [email protected]
    ✅ [email protected]
    ✅ [email protected]

    ❌ no-at-symbol.com
    ❌ @missing-local.com
    ❌ [email protected]

    Simpler Alternative (Basic Validation)

    If you only need lightweight validation:

    regex
    ^[^\s@]+@[^\s@]+\.[^\s@]{2,}$  

    Note: Fully RFC 5322–compliant email regexes are extremely complex. The pattern above covers the vast majority of real-world emails while remaining practical and readable.

  • ĐẦU VÀO

    ip

    ĐẦU RA

    Regular Expression for ip

    IPv4 Address
    regex
    ^(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$  
    Explanation
    PartMeaning
    25[0-5]Matches 250–255
    2[0-4]\dMatches 200–249
    1\d\dMatches 100–199
    [1-9]?\dMatches 0–99 (no leading zeros)
    \.){3}The dot separator repeated 3 times
    ^...$Anchors - whole string must be a valid IP
    Examples
    • ✅ 192.168.1.1
    • ✅ 255.255.255.255
    • ✅ 0.0.0.0
    • ❌ 256.1.1.1 (octet out of range)
    • ❌ 192.168.1 (missing octet)
    • ❌ 01.2.3.4 (leading zero)
    Bonus: IPv6 (simplified, full form)
    regex
    ^(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$  

    ⚠️ Note: A complete IPv6 regex (with :: compression) is significantly longer; the above matches only the uncompressed full form like 2001:0db8:85a3:0000:0000:8a2e:0370:7334.

    Tip

    For production code, prefer a language library (e.g., ipaddress in Python, net.ParseIP in Go) rather than regex for full IP validation.

Những mẫu tương tự khác. Dùng thử miễn phí, hầu hết không cần đăng ký.

Xem tất cả mẫu

Được những người sáng tạo mỗi ngày yêu thích.

Điểm Trustpilot của chúng tôi

Làm được nhiều hơn với tài khoản miễn phí.

Lưu kết quả, tiếp tục từ chỗ bạn đã dừng và dùng 300+ công cụ AI cho viết lách, hình ảnh, video và âm thanh. Nâng cấp bất cứ lúc nào để dùng các mô hình nâng cao.