Re: note 9349 added to ereg

From: Date: Sat, 28 Oct 2000 19:12:46 +0000
Subject: Re: note 9349 added to ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-7156@lists.php.net to get a copy of this message
Meta-characters inside a bracket expression definition do not have special meaning, except from "^" or "-", i.e. the "." does not need to be escaped inside "[-_.]" Run the code below, and you'll see what I mean: $r1 = "[-_.]"; $r2 = "[-_\.]"; $s1 = "to match r1 and r2 . - _"; $s2 = "to match only \ r2"; echo (int) ereg($r1,$s1)."\n"; echo (int) ereg($r2,$s1)."\n"; echo (int) ereg($r1,$s2)."\n"; echo (int) ereg($r2,$s2)."\n"; It will print out: 1 1 0 1 Check your regex(7) man page, and read "Mastering Regular Expressions" it is a great source for all things regex. Your note will be removed. --- aah@acm.org wrote: > More on email validity checking: I may be wrong, > but it seems to me that all the tests above fail to > properly escape the '.' character within the > address. Specifically, I think the regexps which > include sections like '[-_.]' should properly be > '[-_\.]' -- note the escaped '.'. > > http://www.php.net/manual/function.ereg.php > > > -- > PHP Notes Mailing List (http://www.php.net/) > To unsubscribe, e-mail: > php-notes-unsubscribe@lists.php.net > For additional commands, e-mail: > php-notes-help@lists.php.net > To contact the list administrators, e-mail: > php-list-admin@lists.php.net > ===== --- Jesus M. Castagnetto (jcastagnetto@yahoo.com) __________________________________________________ Do You Yahoo!? Yahoo! Messenger - Talk while you surf! It's FREE. http://im.yahoo.com/

« previous php.notes (#7156) next »