Re: regular expression

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

 



Hi  Tanel,

1. only letters

$str = 'helloworld';

if(preg_match("/^[a-zA-Z]*$/",$str))
echo "only letters";
else
echo "failed";

2. only letters and spaces

$str = 'hello world';

if(preg_match("/^[a-zA-Z\s]*$/",$str))
echo "only letters and spaces";
else
echo "failed";


Regards
Peter.M

Tanel Tammik wrote:
How to check with regular expression (preg) if string has:

1. only letters
2. only letters and spaces

Br
Tanel



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[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