bugzy Posted August 9, 2012 Share Posted August 9, 2012 Hello guys.. I'm not into regex yet How will I edit this regex so it would allow letters only and spaces? preg_match('/^\pL+$/u', $fname) Quote Link to comment Share on other sites More sharing options...
Christian F. Posted August 9, 2012 Share Posted August 9, 2012 What you want is a Character Class. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted August 9, 2012 Share Posted August 9, 2012 You don't need a regex pattern at all for that. if( ctype_alpha( str_replace(' ', '', $string)) ) { echo 'Valid'; } else { echo 'Invalid'; } Quote Link to comment Share on other sites More sharing options...
bugzy Posted August 9, 2012 Author Share Posted August 9, 2012 You don't need a regex pattern at all for that. if( ctype_alpha( str_replace(' ', '', $string)) ) { echo 'Valid'; } else { echo 'Invalid'; } Thanks Pikachu2000! This works! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.