It seems I had an error with the replaceAll which is supported on ES12+ thanks for the help. (had to use replace)
It is now working as expected.

Thanks for the help.