preg_match
| From: | James Duncan | Date: | Sat, 03 Mar 2001 00:19:59 +0000 |
| Subject: | preg_match | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-5797@lists.php.net to get a copy of this message | ||
Help,
This is driving me mad and I know there must be a very simple solution. Im
trying to detect if my strings contain ONLY certain values. For instance, I
m trying to limit my $name string to just a-z (case insensitive)
characters. Im trying to do this with preg_match (unless there is an easier
way). However, Im failing badly. This is what I have so far:
if (preg_match ("/[a-z]/i", $name))
{
echo "string only contains characters ranging between a to z";
}
else
{
echo "string contains characters outside of the a to z range";
}
This checks for the occurrence of any a-z characters in the string. However,
want I require is for it to allow JUST those characters. At the moment if
$name = abc1 then True is returned (I want False returned here because of
the 1). I dont know how to write this functionality in preg_match format
:-(
Please help
Thanks
James