^ # start of string
[$rfc5322_atext\\.]+ # user part which is liberal :p
@ # 'apostrophe'
- [$rfc1034_ldh_str] # Domain first character
- [$rfc1034_ldh_str\\.]+ # Second char and following can include dot
+ [$rfc1034_ldh_str]+ # First domain part
+ (\\.[$rfc1034_ldh_str]+)+ # Following part prefixed with a dot
$ # End of string
/ix" ; // case Insensitive, eXtended
$this->valid( 'USER@eXAMPLE.com' );
}
function testEmailWithAPlusInUserName() {
- $this->valid( 'user+sub@localdomain' );
+ $this->valid( 'user+sub@example.com' );
+ $this->valid( 'user+@example.com' );
}
function testEmailWithWhiteSpacesBeforeOrAfterAreInvalids() {
$this->invalid( " user@host" );
function testEmailDomainCanNotBeginWithDot() {
$this->invalid( "user@." );
$this->invalid( "user@.localdomain" );
- $this->valid( "user@localdomain." );
- $this->valid( "user.@localdomain" );
- $this->valid( ".@localdomain" );
- $this->valid( ".@a............" );
+ $this->invalid( "user@localdomain." );
+ $this->invalid( "user.@localdomain" );
+ $this->invalid( ".@localdomain" );
+ $this->invalid( ".@a............" );
}
function testEmailWithFunnyCharacters() {
$this->valid( "\$user!ex{this}@123.com" );
// "apostrophe"
'@'
+
- // Domain first character
- '[' + rfc1034_ldh_str + ']'
+ // Domain first part
+ '[' + rfc1034_ldh_str + ']+'
+
- // second char and following can include dot
- '[' + rfc1034_ldh_str + '\\.' + ']' + '+'
+ // Second part and following are separated by a dot
+ '(\\.[' + rfc1034_ldh_str + ']+)+'
+
// End of string
'$',