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


Reply via email to