First, an editorial comment : Ay yi yi! (I'm not getting on your case, it's an easy enough sort of trap to fall into, which I can say having done it myself!) But oy veh, is that hard to read!
Instead of using that mess of alternations, use a character class.
Better yet, since it seems your aim is to exclude everything that's neither an underscore, space, or alphanumeric, why not say what you want and say if it finds anything that's not in that set, reject it.
so
if (ereg("[[:alnum:]{:space:]_]", $username)
$uerror=1;
The caret ^ at the beginning of the character class says "not", roughly, so the condition reads
if $username contains anything that's not a space, alphanumeric, or underscore character ...
(you don't need the braces around "$uerror=1;" because it's only one line.)
I hope that helps.
AC