suit: "perfekte" Validierung von E-Mail-Adressen, IP-Adressen usw

Beitrag lesen

Das RegEx-Monster versteckt sich stattdessen in dieser Funktion selbst.

Firma dankt - auch ohne entsprechende PHP-Version lässt sich das dann nutzen.

preg_match("/^((\\\"[^\\\"\\f\\n\\r\\t\\b]+\\\")|([A-Za-z0-9_][A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*(\\.[A-Za-z0-9_\\!\\#\\$\\%\\&\\'\\*\\+\\-\\~\\/\\^\\`\\|\\{\\}]*)*))@((\\[(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))\\])|(((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9]))\\.((25[0-5])|(2[0-4][0-9])|([0-1]?[0-9]?[0-9])))|((([A-Za-z0-9])(([A-Za-z0-9\\-])*([A-Za-z0-9]))?(\\.(?=[A-Za-z0-9\\-]))?)+[A-Za-z]+))$/D",  
$e_mail_adresse);

Welche Einschränkungen?

Ich meinte die Längenbeschränkung. Die Antwort ist, PHP ignoriert sie - genauso wie E-Mail-Adressen mit IDN im domain-part. Ansonsten scheint der Ausdruck super zu funktionieren.

RFC 5321: 4.5.3.1. Size Limits and Minimums
[...]
4.5.3.1.1. Local-part
   The maximum total length of a user name or other local-part is 64
   octets.

4.5.3.1.2. Domain
   The maximum total length of a domain name or number is 255 octets.

4.5.3.1.3. Path
   The maximum total length of a reverse-path or forward-path is 256
   octets (including the punctuation and element separators).