C# Beginner: Delete ALL between two characters in a string (Regex?)

前端 未结 2 1496
再見小時候
再見小時候 2021-01-19 09:49

i have a string with an html code. i want to remove all html tags. so all characters between < and >.

This is my code snipped:

WebClient wClient          


        
相关标签:
2条回答
  • 2021-01-19 10:10

    According to Ravi's answer, you can use

    string noHTML = Regex.Replace(inputHTML, @"<[^>]+>|&nbsp;", "").Trim();
    

    or

    string noHTMLNormalised = Regex.Replace(noHTML, @"\s{2,}", " ");
    
    0 讨论(0)
  • 2021-01-19 10:14

    Try this:

    txtSourceCodeFormatted.Text = Regex.Replace(SourceCode, "<.*?>", string.Empty);
    

    But, as others have mentioned, handle with care.

    0 讨论(0)
提交回复
热议问题