1 – can you try to escape the regex by using "\\."
2 – if not you can find the position of the dot by find($variable, '.') and take a substring from the start of a word and replace the substring till the positiyon by your self (or something like that with replacing substrings based on found position of dot)