Regular expression problems
| From: | Lee P. Reilly | Date: | Mon, 14 Apr 2003 15:44:55 +0000 |
| Subject: | Regular expression problems | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-143793@lists.php.net to get a copy of this message | ||
Hi there,
I am using a regular expression to try and weed out unwanted characters
in user input. What I am trying to do, is allow input to contain
alpha-numeric characters and some other standard characters e.g. "-",
"!", "&", etc. I am trying to accomplish this like so:
else if (eregi("^[a-zA-Z0-9!@#\$%^&\*\(\),/.//<>\?;':\"~`_\+\|\\-\\t\n\
]*$", $sessname))
return true
The problem is that this regular expresion returns FALSE if there is a
"-" character anywhere in the input. Anyone offer any pointers?
Thanks in advance.
- Best regards,
Lee