Re: regexp question
| From: | Hans H. Anderson | Date: | Fri, 11 Aug 2000 18:35:38 +0000 |
| Subject: | Re: regexp question | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-11391@lists.php.net to get a copy of this message | ||
how about
ereg("[^-A-Za-z0-9_]",$blah);
put the dash first, so the character class knows you aren't spanning
characters (being last probably worked, too, but Mastering Regular
Expressions says put it first).
I don't know that you need to start with ^ and end with $, as you are
looking for anything that isn't A-Z, a-z, 0-9 or - or _. The + at the end
probably isn't necessary, either.
Hans
On Fri, 11 Aug 2000, Ryan J Nichols wrote:
> can I get a regexp that verifies a string is only 0-9 a-z A-Z or contains _ and -
>
> ereg("^[^A-Za-z0-9\d_-]+$",$bah)
> does not work.
>
> I've been toying with this for a while with no success, in addition to the answer a nice
> url to a tutorial on these things would be appreciated.
>
> Thanks in advance,
>
> Ryan
>
>
Hans Anderson ~ me@hansanderson.com
PO Box 426, Missoula, MT 59806 | PHP, Search Engines, SQL
(800)397-9116 / (406)549-6524 | Databases, Flash Multimedia,
http://www.hansanderson.com | Killer Audio Production,
http://www.goofiness.com | Minty Fresh Breath.