in reply to regex optimization

You have a few {1}'s in your first regex which of course do nothing since matching 1 of something is the default. Since the single .* is the only part of the regex that can match one of the illegal characters you can reduce it to a single regex by replacing .* with [^.\!\+=\[\]\*<>\$\%\@\?\&:\/\\\{\}]*. Also the /g modifier on the second (and now redundant) regex isn't doing anything useful that I can see.