I want to replace some words in the text, but only on conditions, for example, if each of them is surrounded by spaces.
For this, I use:
Regex rx = Regex(@"\s+" + word + @"\s+"); str = rx.Replace(str, word2);
In the end, I also replaced the spaces (and all other specified environments). How can I get around this?
source share