un*****@gmail.com wrote:
I'm trying to design a regular expression that matches (using
preg_match()) when a string is a well-formed Email address.
So far I have this: /^[A-Z0-9._%\-]+@[A-Z0-9._%\-]+\.[A-Z]{2,4}$/i
I got that from reguar-expressions.info. But PHP keeps complaining of
"Unknown modifier 'Z'".
For the life of me I can't figure out how 'Z' is a modifier.
Can anyone help? Thanks much.
My PHP does not complain.
php$ php --version
PHP 4.3.9-1 (cli) (built: Oct 5 2004 08:45:32)
Copyright (c) 1997-2004 The PHP Group
Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies
php$ cat preg.php
<?php
$regexp = '/^[A-Z0-9._%\-]+@[A-Z0-9._%\-]+\.[A-Z]{2,4}$/i';
$email = 'h*****@dodgeit.com';
if (preg_match($regexp, $email)) {
echo 'Match!';
}
echo "\n";
?>
php$ php preg.php
Match!
Also see
http://www.ex-parrot.com/~pdw/Mail-RFC822-Address.html
This is a Perl regexp, it should work with PHP unchanged (never tried it).
--
Mail sent to my "From:" address is publicly readable at
http://www.dodgeit.com/
== ** ## !! !! ## ** ==
TEXT-ONLY mail to the complete "Reply-To:" address ("My Name" <my@address>) may
bypass the spam filter. I will answer all pertinent mails from a valid address.