note 56620 added to function.ereg

From: Date: Fri, 09 Sep 2005 13:01:04 +0000
Subject: note 56620 added to function.ereg
Groups: php.notes 
Request: Send a blank email to php-notes+get-94962@lists.php.net to get a copy of this message
It was really hard for me to get the next checker!!! I think the information displayed here is really scarce. I had to get a PHP book to get the following information: to indicate the start of a string : ^, nothing comes before it you'll need to escape the following characters (with a backslash \ ) : . \ ! + * ? [ ] ^ $ ( ) = ! < > | and : the characters above each have a special meaning, that's why you need to escape them to include them in a string. * means : match this pattern 0 or more times ? means : match this pattern exactly 1 time + means : match this pattern 1 or more times and $ means the definite end of a string, nothing may come afterward. With this information I could finaly check a complete string containing only a few allowed character types : ereg("^([-a-zA-Z0-9_\.\!@#\$&\*\+\=\|])*$" , $var) some of the other tips here let other character through like < and >, which I did not want to get past my check! Hope this helps out. ---- Manual Page -- http://www.php.net/manual/en/function.ereg.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56620 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56620&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56620&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56620&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56620&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56620&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56620&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56620&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94962) next »