Way to have String.Replace only hit “whole words”

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.

69
задан Vaccano 26 May 2011 в 18:56
поделиться