Re: regular expression

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux