Re: Regular expression problems
| From: | Jason Wong | Date: | Mon, 14 Apr 2003 15:45:35 +0000 |
| Subject: | Re: Regular expression problems | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-143795@lists.php.net to get a copy of this message | ||
On Monday 14 April 2003 23:44, Lee P. Reilly wrote:
> 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?
If you're matching a range, the hyphen needs to be at the end.
--
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
You are so boring that when I see you my feet go to sleep.
*/