RE: [PHP] Regular Expression
| From: | Dan Joseph | Date: | Tue, 01 Jul 2003 14:23:36 +0000 |
| Subject: | RE: [PHP] Regular Expression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-153564@lists.php.net to get a copy of this message | ||
Hi,
That might actually be a good solution for another item I'm working with.
Thanks for the tip.
-Dan Joseph
> -----Original Message-----
> From: Jay Blanchard [mailto:jay.blanchard@niicommunications.com]
> Sent: Tuesday, July 01, 2003 10:10 AM
> To: Dan Joseph; php-general@lists.php.net
> Subject: RE: [PHP] Regular Expression
>
>
> [snip]
> That would have been my first choice also, however, with the #
> and - being
> legal, things like ctype_alnum and others don't work out.
> [/snip]
>
> Here is an example of something that I did before;
>
> $alphachar = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
> $ld1alpha = strspn($ld1, $alphachar);
> if(strlen($ld1) != $ld1alpha){
> $err[$i] = "The LD1 may only contain alpha characters.<br>\n";
> $i++;
> }
>
> int strspn ( string str1, string str2) - Returns the length of the
> initial segment of str1 which consists entirely of characters in str2.
> You could add - and # to $alphachar
> Now, in this case $ld1aplpha would be the same length as the string
> length of the input field where the characters are contained in
> $alphachar. This is used as one of the steps in a
> verification/validation procedure on a large internal form.
>
> Just another solution to the problem
>
> HTH!
>