正規表現例
/^[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])?)*$/
上記の正規表現は、HTML5のinput[type=email]要素に関するものです。この正規表現は、メールアドレスの定義に「意図的に違反(willful violation)」しています。
This requirement is a willful violation of RFC 5322, which defines a syntax for e-mail addresses that is simultaneously too strict (before the "@" character), too vague (after the "@" character), and too lax (allowing comments, whitespace characters, and quoted strings in manners unfamiliar to most users) to be of practical use here.
メールアドレスを正規表現でチェックするには、RFC5322で定義されているメールアドレスを完全にサポートすることの困難さや、RFCに違反しているが一般に使われている形式のメールアドレスへの対応の是非などの問題があります。
最終更新:2017年12月13日 05:47