Page 1 of 1

string pattern for ereg function

Posted: Tue Apr 20, 2004 1:42 am
by bugthefixer
any1 can tel me string pattern for ereg function which accept small and capital alphabets and a blank space

Posted: Tue Apr 20, 2004 3:12 am
by JayBird
Why not try it yourself by reading the manual at http://www.php.net, then, if you get stuck, come back with the code you have written and we will help you.

Mark

i hav tried

Posted: Tue Apr 20, 2004 3:22 am
by bugthefixer
the code i used was

Code: Select all

<?php
ereg("^[a-zA-Z\s]+$",$str) 

?>
it recognizes alphabets but not spaces..kan u tel me y

Posted: Tue Apr 20, 2004 5:45 am
by redmonkey
\s is not recoginsed as having any special meaning with POSIX Extended regex.

You could use either..

Code: Select all

ereg("^[a-zA-Z[]]+$",$str)
or..

Code: Select all

ereg("^[a-zA-Z ]+$",$str)
// space after the Z