remove only some html tags on c#

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

I have a string:

string hmtl = "
xpto

and need to remove the tags of

5条回答
  •  伪装坚强ぢ
    2021-01-03 09:47

    If you are just removing div tags, this will get div tags as well as any attributes they may have.

    var html = 
      "
    xpto
    Other text
    test
    " var pattern = "@"(\)""; // Replace any match with nothing/empty string Regex.Replace(html, pattern, string.Empty, RegexOptions.IgnoreCase);

    Result

     xpto Other text test
    

提交回复
热议问题