php3-list | 199908
Date: 08/11/99
- Next message: Chad Williams: "[PHP3] header location not working for certain browsers"
- Previous message: Jon Griffin: "RE: [PHP3] ODBC connection to MS Access"
- In reply to: Paul Schreiber: "[PHP3] regex bug?"
- Next in thread: Teodor Cimpoesu: "Re: [PHP3] regex bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Wed, 11 Aug 1999, Paul Schreiber wrote:
> function validateEmail ($address) {
> return (!( ereg("( <email protected>*@)|(\.\.)|(@\.)|(\.@)|(^\.)", $address) ||
> !ereg("^.+\@(\[?)[a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$",
> ^^^^^
> $address))
> );
> }
>
> I switched the order of \.\- and it worked. comments?
You fixed a bug. Inside of [] in a regex, if you want a literal "-" it
must be at the beginning or end of the characters; otherwise, it specifies
a range of characters, as in a-z. Also, I haven't doublechecked this, but
I don't think you need to escape "." and "-" inside of [], since it's
clear they represent literal "." and "-", not regex metacharacters.
-adam
-- / adam maccabee trachtenberg | visit college life online \ \ adam <email protected> | http://www.student.com /-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Chad Williams: "[PHP3] header location not working for certain browsers"
- Previous message: Jon Griffin: "RE: [PHP3] ODBC connection to MS Access"
- In reply to: Paul Schreiber: "[PHP3] regex bug?"
- Next in thread: Teodor Cimpoesu: "Re: [PHP3] regex bug?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

