php/ereg question



I am trying to write a script, and i need to use ereg to check if the username is a valid format, it must follow this format…

a-z A-Z 0-9, 5 to 16 characters, and no spaces, so i tried doing this with ereg,

if(ereg("^[A-Za-z0-9].[^s]{5,16}$", $name)){
	echo "valid";

but that didnt work, can anyone help me please?


If you don’t specify the space as a valid character, you don’t need to validate it’s invalid.

ereg("^[A-Za-z0-9]{5,16}$", $name)


thanks alot