Skip to content

Email Regex For Different Languages And Scripts

Below are some useful regex for email validation for common languages and scripts:

  1. General Email Regex (RFC 5322 Official Standard)

    (?:[a-z0-9!#$%&’*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&’*+/=?^_`{|}~-]+)*|”(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*”)@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?: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]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])

     

  2. Python

    r"(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)"

     

  3. Javascript

    /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[09]{1,3}\.[09]{1,3}\.[09]{1,3}\.[09]{1,3}])|(([azAZ\09]+\.)+[azAZ]{2,}))$/

     

  4. HTML5

    <input type="email" placeholder="Enter your email" />

    regex used in type=”email” from W3C:
    /^[a-zA-Z0-9.!#$%&’*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/

  5. Swift

    [AZ09az._%+]+@[AZaz09.]+\\.[AZaz]{2,64}

     

  6. PHP

    /^(?!(?:(?:\x22?\x5C[\x00\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){255,})(?!(?:(?:\x22?\x5C[\x00\x7E]\x22?)|(?:\x22?[^\x5C\x22]\x22?)){65,}@)(?:(?:[\x21\x23\x27\x2A\x2B\x2D\x2F\x39\x3D\x3F\x5E\x7E]+)|(?:\x22(?:[\x01\x08\x0B\x0C\x0E\x1F\x21\x23\x5B\x5D\x7F]|(?:\x5C[\x00\x7F]))*\x22))(?:\.(?:(?:[\x21\x23\x27\x2A\x2B\x2D\x2F\x39\x3D\x3F\x5E\x7E]+)|(?:\x22(?:[\x01\x08\x0B\x0C\x0E\x1F\x21\x23\x5B\x5D\x7F]|(?:\x5C[\x00\x7F]))*\x22)))*@(?:(?:(?!.*[^.]{64,})(?:(?:(?:xn)?[az09]+(?:[az09]+)*\.){1,126}){1,}(?:(?:[az][az09]*)|(?:(?:xn)[az09]+))(?:[az09]+)*)|(?:\[(?:(?:IPv6:(?:(?:[af09]{1,4}(?::[af09]{1,4}){7})|(?:(?!(?:.*[af09][:\]]){7,})(?:[af09]{1,4}(?::[af09]{1,4}){0,5})?::(?:[af09]{1,4}(?::[af09]{1,4}){0,5})?)))|(?:(?:IPv6:(?:(?:[af09]{1,4}(?::[af09]{1,4}){5}:)|(?:(?!(?:.*[af09]:){5,})(?:[af09]{1,4}(?::[af09]{1,4}){0,3})?::(?:[af09]{1,4}(?::[af09]{1,4}){0,3}:)?)))?(?:(?:25[05])|(?:2[04][09])|(?:1[09]{2})|(?:[19]?[09]))(?:\.(?:(?:25[05])|(?:2[04][09])|(?:1[09]{2})|(?:[19]?[09]))){3}))\]))$/iD

     

  7. Perl >= 5.10

    /(?(DEFINE)(?<address>(?&mailbox) | (?&group)) (? (?&name_addr) | (?&addr_spec)) (? (?&display_name)? (?&angle_addr)) (? (?&CFWS)? < (?&addr_spec) > (?&CFWS)?) (? (?&display_name) : (?:(?&mailbox_list) | (?&CFWS))? ; (?&CFWS)?) (? (?&phrase)) (? (?&mailbox) (?: , (?&mailbox))*) (? (?&local_part) \@ (?&domain)) (? (?&dot_atom) | (?&quoted_string)) (? (?&dot_atom) | (?&domain_literal)) (? (?&CFWS)? \[ (?: (?&FWS)? (?&dcontent))* (?&FWS)? \] (?&CFWS)?) (? (?&dtext) | (?&quoted_pair)) (? (?&NO_WS_CTL) | [\x21-\x5a\x5e-\x7e]) (? (?&ALPHA) | (?&DIGIT) | [!#\$%&’*+-/=?^_`{|}~]) (? (?&CFWS)? (?&atext)+ (?&CFWS)?) (? (?&CFWS)? (?&dot_atom_text) (?&CFWS)?) (? (?&atext)+ (?: \. (?&atext)+)*) (? [\x01-\x09\x0b\x0c\x0e-\x7f]) (? \\ (?&text)) (? (?&NO_WS_CTL) | [\x21\x23-\x5b\x5d-\x7e]) (? (?&qtext) | (?&quoted_pair)) (? (?&CFWS)? (?&DQUOTE) (?:(?&FWS)? (?&qcontent))* (?&FWS)? (?&DQUOTE) (?&CFWS)?) (? (?&atom) | (?&quoted_string)) (? (?&word)+) # Folding white space (? (?: (?&WSP)* (?&CRLF))? (?&WSP)+) (? (?&NO_WS_CTL) | [\x21-\x27\x2a-\x5b\x5d-\x7e]) (? (?&ctext) | (?&quoted_pair) | (?&comment)) (? \( (?: (?&FWS)? (?&ccontent))* (?&FWS)? \) ) (? (?: (?&FWS)? (?&comment))* (?: (?:(?&FWS)? (?&comment)) | (?&FWS))) # No whitespace control (? [\x01-\x08\x0b\x0c\x0e-\x1f\x7f]) (? [A-Za-z]) (? [0-9]) (? \x0d \x0a) (? “) (? [\x20\x09]) ) (?&address)/x</address>
     

  8. Java

    (?:[a-z0-9!#$%&’*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&’*+/=?^_`{|}~-]+)*|”(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])*”)@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\[(?:(?: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]?|[a-z0-9-]*[a-z0-9]:(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]|\\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])
     

  9. .NET (general pattern match

    ^\w+([-+.’]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$

  10. C#

    ^(?(")(".+?(?<!\\)"@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&’\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$

Published inProgramingRegex

One Comment

Leave a Reply

Your email address will not be published. Required fields are marked *