There you will find the rules for SQL Server string identifiers:
Database Identifiers[
^] (see 'Rules for Regular Identifiers' in this page).
[Correction] I did not read the code correctly. Apparently you are trying to replace all characters that are not a word, a point, a @, # or $.
I don't think a point can be part of an identifier.