Re: regex for cleaning up username
| From: | CC Zona | Date: | Sun, 22 Jul 2001 21:46:23 +0000 |
| Subject: | Re: regex for cleaning up username | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-59093@lists.php.net to get a copy of this message | ||
In article <DBEIKNMKGOBGNDHAAKGNAENCHBAA.dave@nexusinternetsolutions.net>,
dave@nexusinternetsolutions.net (Dave) wrote:
> Cannot seem to get a regex to check a string for the following
>
> space tab ' " ! @ # $ % ^ & * ( ) + = : ; / \
>
> if(preg_match('[\'" ,!@#$%\^&*()+=:;/\\]',$mystring))
You need pattern delimiters with preg_* expressions. Right now it's using
your square brackets at the delimiters, so instead of a character class
("match on any of these"), you're trying to match a string matching the
entire sequence of characters between the square brackets. Try:
if(preg_match('|[\'" ,!@#$%\^&*()+=:;/\\]|',$mystring))
--
CC