【发布时间】:2010-02-20 05:54:24
【问题描述】:
我可以得到不带html标签的字符串,它会显示在webbrowser控件上吗?
就像我有 String str = "html hello html" 然后我想找到像 hello 这样的字符串。
我该怎么做?
【问题讨论】:
标签: c# .net winforms webbrowser-control
我可以得到不带html标签的字符串,它会显示在webbrowser控件上吗?
就像我有 String str = "html hello html" 然后我想找到像 hello 这样的字符串。
我该怎么做?
【问题讨论】:
标签: c# .net winforms webbrowser-control
正则表达式并不适合 HTML。正则表达式用于常规文本,而不是 HTML。
使用 HTML 解析器库,例如免费的开源 HTML Agility Pack。它与HTML-to-Text converter sample 捆绑在一起。
【讨论】:
< 开头并以> 结尾的东西”)非常适合正则表达式。
您可以使用正则表达式来去除 html 标签,例如:
string html = "Your html string";
string x = Regex.Replace(html,@"<(.|\n)*?>", string.Empty);
【讨论】: