tags:

views:

20

answers:

1
/* Check if username is not valid */
     else if(!eregi("/[^a-z0-9\s\' ']/i", $subuser)){
        $form->setError($field, "* Username not valid");
     }

How to I allow for spaces to be allowed in the eregi line??

On a sidenote... I was going to use:

$input_name = preg_replace('/\s\s+/', ' ', $input_name)

to strip excess white space, can this be done in a one liner using eregi?

A: 

If you're using PHP5, you should drop ereg functions altogether. They've already been deprecated in 5.3.

if (!preg_match('/[\w\s]+/',$subuser)
   echo 'Invalid';
stillstanding
Thank you, problem solved! Also, thanks for the heads up on ereg!
Callum Johnson