Can someone please help me to re write the regex which can work in safari?
I find out that safari doesn’t support lookbehind but still not able to re write the whole regex which can be good for safari.
Modify your pattern to avoid the negative lookbehind. Since you seem to want a non whitespace character as the last character, just use a character class for that.
Side note: your current pattern looks wrong for what you are trying to match.