I’m working on a script to validate usernames, ensuring they consist only of allowed characters.

I attempted the code below, but it appears to only verify whether the username includes any of the specified characters, so it may also include characters that are not permitted. I also tried excluding unwanted characters, but that didn’t work for things like smiley faces.

How can I modify the script to filter usernames that include only allowed characters?