DragonFire-N[R] Posted October 7, 2007 Share Posted October 7, 2007 Hello, I have tried many expressions but I am unable to find one that works. Could someone please post an expression that matches alpha characters and spaces only? I've tried this: if ( preg_match( '#[a-z\s]#is', $string ) ) but it doesn't work like I had hoped. I haven't found anything $string could be that would make preg_match return false. Also, if someone could also include a preg_replace expression that would eliminate all characters from a string except alpha characters and spaces that would be great Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/72147-solved-preg-question/ Share on other sites More sharing options...
sKunKbad Posted October 7, 2007 Share Posted October 7, 2007 if (preg_match('/^[a-z ]+$/i', $string)) { } else { } and $pattern = '/[^a-z ]/i'; preg_replace($pattern, "", $string); test those and see how they work for you Link to comment https://forums.phpfreaks.com/topic/72147-solved-preg-question/#findComment-363812 Share on other sites More sharing options...
DragonFire-N[R] Posted October 7, 2007 Author Share Posted October 7, 2007 Ah, now I see what I was doing wrong and why it didn't work Thanks a million Link to comment https://forums.phpfreaks.com/topic/72147-solved-preg-question/#findComment-364113 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.