Re: regular expression
| From: | Ashley Sheridan | Date: | Tue, 01 Jun 2010 15:29:30 +0000 |
| Subject: | Re: regular expression | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-305693@lists.php.net to get a copy of this message | ||
On Tue, 2010-06-01 at 18:19 +0300, Tanel Tammik wrote:
> How to check with regular expression (preg) if string has:
>
> 1. only letters
> 2. only letters and spaces
>
> Br
> Tanel
>
>
>
Use preg_match() to find an expression within a string. You can use
something like this to grab check if a string contains only letters or
numbers:
if(preg_match('/^[a-zA-Z0-9]+$/'), $string)
{
}
Thanks,
Ash
http://www.ashleysheridan.co.uk