note 56620 deleted from function.ereg by tularis
| From: | tularis@php.net | Date: | Thu, 31 May 2007 13:23:59 +0000 |
| Subject: | note 56620 deleted from function.ereg by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-127068@lists.php.net to get a copy of this message | ||
Note Submitter: eregitate
----
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.