Use string.Replace to match whole words
问题 I'm using NET 2.0 and WinForms. Currently, I need a code to replace a string with another one in a given text, but in the text it should only look for whole words. What I mean is: string name = @"COUNTER = $40 CLOCK_COUNTER = $60"; name = name.Replace("COUNTER", "COUNT"); It should only replace the first instance of COUNTER with COUNT , because that's whole word. However, it seems string.Replace does not take whole word into consideration. Please don't recommend regex. I have already tried it