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

Reply via email to