Claus Pfisterer Mon May 13 11:31:38 -0400 2013

Subject: REGEX of E-Mail validation seems to be invalid

I use the example of email-validation as on the phpactiverecord website in section validates_format_of:
http://www.phpactiverecord.org/projects/main/wiki/Validations

The example

static $validates_format_of = array(array('email', 'with' =>'/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}$/')

seems to be invalid if some clients told me they have an emailadress with a dash (-)in it.
so i fixed this by adding several chars into the regex expression as follows:

array('email', 'with' => '/^[^0-9][A-z0-9._%-]+([.][A-z0-9._%-]+)*[@][A-z0-9._%-]+([.][A-z0-9._%-]+)*[.][A-z]{2,4}$/', 'message' => 'E-Mail-Adresse ist ung├╝ltig'),

if added these chars because i found on this website:
http://www.regular-expressions.info/regexbuddy/email.html
the following regex:

\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b