I am currently using this code to replace exact match. However this does not work, it also removed where the words appear in other words.
Example:
string pattern = "(?i)(flo)";
jobTitle = Regex.Replace("Florist of Vinyl Flowers of flo abc", pattern, string.Empty);
This is making the string :
orist of Vinyl owers
Which is wrong it should only remove flo from the string, and if I use :
string pattern = "(?i)\b(flo)\b";
It does not match however even if there is a complete word in there it wont match, nothing matches/
UPDATE :
The complete code runs like this:
splitter = wordToremoveTitle.Split('|');
if (splitter.Length > 0)
{
for (int t = 0; t < splitter.Length ; t++)
{
String pattern = @"(?i)\b(" + splitter[t] + ")\b";
jobTitle = Regex.Replace(jobTitle, pattern, string.Empty);
}
you was so close, regex:
(?i)\bflo\bif word mean “Florist” and “Flowers” but not “flo” use this one
(?i)\b[^ ]*flo[^ ]*\b