Reputation: 20049
I'm trying to check a string for spaces, tabs et al & am using this:
if (preg_match('/\s*/', $username)) {
echo 'no spaces allowed in username.';
}
However it always thinks there are spaces in the username even if there isn't.
What am I doing wrong?
Upvotes: 0
Views: 44
Reputation: 7576
*
means zero or more times.
So
if (preg_match('/\s+/', $username)) {
Upvotes: 5