c# - Regex.Replace not replacing the whole string instead replacing chars in string -
c# - Regex.Replace not replacing the whole string instead replacing chars in string -
my code follow:
articlecontent = regex.replace(_article.article, "[quote]", "<p class='quote'><span style='font-size:1.8em !important;'>" + _article.newfields.quotes + "</span></p>", regexoptions.ignorecase);
the problem i'm facing here is, regex not replacing whole occurrence of string '[quote]'. instead searching letters q,u,o,t,e , replacing them replace string. know issue because of square brackets, want replaced well. please help.
you must escape square brackets! , don't forget regexp case sensitive. here's correction code:
articlecontent = regex.replace(_article.article, "\[quote\]", "<p class='quote'><span style='font-size:1.8em !important;'>" + _article.newfields.quotes + "</span></p>", regexoptions.ignorecase);
by way, don't see accourrence of 'quote' enclosed in brackets, i'm not sure got you're trying do...
c# .net regex string replace
Comments
Post a Comment