String replace is not working as expected. Regex variable was not in use.

Pattern was not used in process string function. If you use two times same variable in the string first one is replace but second one is not.