1

什么是c#正则表达式来替换打开和关闭 pike 之间的所有文本/字符?

例如:

this is an <example> that <needs> to turn into

=> this is an that to turn into
4

1 回答 1

5

而不是正则表达式,我会使用像HtmlAgilityPack这样的Html 解析器

string html = "this is an <example> that <needs> to turn into";
var doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(html);
var text = doc.DocumentNode.InnerText;

但是如果你必须使用正则表达式

var text = Regex.Replace(html, @"\<.+\>", String.Empty);
于 2013-04-15T17:32:19.307 回答