2
我想要一个正则表达式来从字符串中删除html标记和&等等。我得到的正则表达式是移除html标签,但不提及其他人。我使用的.Net 4string删除htmls
感谢
CODE:
String result = Regex.Replace(blogText, @"<[^>]*>", String.Empty);
我想要一个正则表达式来从字符串中删除html标记和&等等。我得到的正则表达式是移除html标签,但不提及其他人。我使用的.Net 4string删除htmls
感谢
CODE:
String result = Regex.Replace(blogText, @"<[^>]*>", String.Empty);
要建立在您已创建的内容上,您可以将其更改为以下内容:
String result = Regex.Replace(blogText, @"<[^>]*>|&\w+", String.Empty);
这意味着...
&
至少一个字字符\w
- 多达可能。这两个都不能在所有讨厌的情况下工作,但通常情况下它确实如此。
不要使用正则表达式,使用HTML敏捷包:如果您想
继续之前,看看这里:http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags – Zruty 2011-05-19 15:58:53
呃哦...... ... – 2011-05-19 15:59:08
正则表达式和HTML从来都不是一个好的组合。看看@ http://stackoverflow.com/questions/5496704/strip-html-and-css-in-c – 2011-05-19 16:00:07