if(preg_match('^((?!&#\d+;)[\x20-\x7E])+$', $username')){//username is ASCII characters from 32-127}else{//username is not valided}