string pattern for ereg function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

string pattern for ereg function

Post by bugthefixer »

any1 can tel me string pattern for ereg function which accept small and capital alphabets and a blank space
User avatar
JayBird
Admin
Posts: 4524
Joined: Wed Aug 13, 2003 7:02 am
Location: York, UK
Contact:

Post 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
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

i hav tried

Post 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
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post 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
Post Reply