خرید بک لینک

Vote count: 0

I'm trying to create a function replacing only whole words, for example:

The sentence : "#testing is #test", if I use Replace("#test", "#cool"), I'll have "#cooling if #cool" but I'd like to have "#testing is #cool"

I've searched and every answer found was :

string pattern = @"b"+previousText+"b";
string myText = Regex.Replace(input, pattern, newText, RegexOptions.IgnoreCase);

However this solution does not work if my previousText (the one I'd like to replace) contains a "#".

Both my previousText and my newText can start with a "#".

What is the solution for this ?

asked 42 secs ago

برچسب: c, replace only whole words, نویسنده: استخدام کار تاريخ: چهارشنبه 20 مرداد 1395 ساعت: 7:11

صفحه بندی