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?

=if(REGEXMATCH(A40,        
"Q|W|E|R|T|Y|U|I|O|P|A|S|D|F|G|H|J|K|L|Z|X|C|V|B|N|M|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z|0|1|2|3|4|5|6|7|8|9|.|_")=True,
"delete","ok")

Thanks