I need a way to have this:
"test, and test but not testing. But yes to test".Replace("test", "text")
return this:
"text, and text but not testing. But yes to text"
Basically I want to replace whole words, but not partial matches.
NOTE: I am going to have to use VB for this (SSRS 2008 code), but C# is my normal language, so responses in either are fine.
A regex is the easiest approach:
The important part of the pattern is the
\bmetacharacter, which matches on word boundaries. If you need it to be case-insensitive useRegexOptions.IgnoreCase: