Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE2 (PHP >=7.3)

/
^(\w+[._%+-]*)+@(([a-zA-Z0--ÿ-]+-?)+\.)+[a-zA-Z]{2,}$
/
gm

Description

This regex will validate pretty much every mail that could exist. It allows aliases and tags in the mail, therefore the mail can contain one or more dots and/or "+" signs (Exemple: exemple.test.alias+tag+tag2). It also allows Internationalized Domain Names (IDNs) (Exemple: @café.com), subdomains (Exemple: domain.subdomain.com) and also "multiple" Top-Level Domain (Exemple: .com or .co.uk)

Submitted by Skyle - 2 years ago (Last modified 2 years ago)