I suck at Regular Expressions. I've got a string that can only have letters in it, so all I need is a little function to return true if if only has letters or false if there's a number in it. Thanks
function checkstring( $stringvar ){
return ! preg_match( "/[^a-zA-Z]/", $stringvar )
}
Not quite.
This should work.
PHP:function checkstring( $stringvar ){ return ! preg_match( "/[^a-zA-Z]/", $stringvar ) }
How is this any different from what I wrote?
Not quite.
This should work.
PHP:function checkstring( $stringvar ){ return ! preg_match( "/[^a-zA-Z]/", $stringvar ) }
Thanks, that works. However, I forgot to mention that it should allow spaces, how would I modify that to accept spaces as well?
[^a-zA-Z ]
[^a-zA-Z\s]
Here is a good site to test PHP regular expressions : http://www.solmetra.com/scripts/regex/