@CJha
That is great. I might be forgetting, but I don't think ~ or # are actually regular expression special characters. However, the escape() method may replace every punctuation character with \-character (including non-ASCII characters like copyright) because that never does any harm/is allowed on any punctuation character. Or it might be enough to let * go to \* and then revert any \*s to plain *s (actually .* in your case).