On Thursday 06 April 2006 6:19 am, Angelo Zanetti wrote:
> Hi guys
>
> Been tryin to figure out regex and have found some tutorials but some have
> made things clear and others have confused me.
>
> Anyway for a simple query, if I just wanted to check that a variable has
> only text and numeric characters would I do something like this (i want it
> to fail if it finds a symbol eg: + - { " etc...):
>
> echo  "REG result: " . preg_match('/[a-zA-Z0-9]*/', '{d-fg');
>
> however this resolves to true because there are normal characters
> (alphabetical characters) so how do I make the expression fail because of
> the { and - characters in the string?
>
> You can also list which characters you DON'T want -- just use a '^' as the
> first symbol in a bracket expression (i.e., "%[^a-zA-Z]%" matches a string
> with a character that is not a letter between two percent signs). But that
> would mean that I would have to list each symbol I dont want and that would
> be undesireable as it would be better to list exactly what the acceptable
> characters are.
>
> Can anyone give me some insight as to where I'm going wrong?
>
> thanks
>
> --
>
> Angelo

I found an AJAX regex tester the other day. It'll check PCRE, Posix, and 
Javascript. Don't know how useful this is, but thought I'd throw it into this 
thread.

http://rexv.org/

-- 
Joe Henry
www.celebrityaccess.com
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to