remove only some html tags on c#

后端 未结 5 2197
猫巷女王i
猫巷女王i 2021-01-03 09:06

I have a string:

string hmtl = "
xpto

and need to remove the tags of

5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-03 09:44

    Use Regex:

    var result = Regex.Replace(html, @"", "");
    

    UPDATED

    as you mentioned, by this code, regex removes all tages else B

    var hmtl = "
    xpto
    "; var remainTag = "B"; var pattern = String.Format("(]*(?)", remainTag ); var result = Regex.Replace(hmtl , pattern, "");

提交回复
热议问题