[thelist] [php] regexp help
Courtenay
court3nay at gmail.com
Tue Oct 19 00:54:12 CDT 2004
Look at www.regexp.info -- it's an amazing resource.
I couldn't replicate your problem.
In a quick check with javascript in firefox javascript debugger (my
quick-n-dirty regexp checker) i did this:
'test ^%'.match(/^[a-zA-Z0-9 -\']+$/)
which gave a false answer.
'test 21af34 '.match(/^[a-zA-Z0-9 -\']+$/)
gave a true answer.
Also, the /i means case insensitive, so the a-zA-Z is redundant, just
a-z will do.
>From what I could see, the % can act like a URL encoding character
thingy (%20 is a space, etc) so it may not being treated as a %
symbol.
What are you actually trying to check? We might be able to
(collectively) write a better regexp!
HTH
courtenay
On Tue, 19 Oct 2004 16:49:55 +1300, Paul Bennett
<paul at web-business-pack.com> wrote:
> one day I'm going to buy that OReilly book, but until then:
>
> Can someone tell me why this check:
>
> if(preg_match("/^[a-zA-Z0-9 -\']+$/i", $value))
> {$response['name'] = true;}
>
> else {$response['name'] = false;}
>
> evaluates to true when $value is something like 'test ^%' - which should
> return false?
>
> thx,
> Paul B
>
> --
>
> * * Please support the community that supports you. * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>
More information about the thelist
mailing list