用c#
正则表达式替换开始和结束长矛之间的所有文字/字符是什么?
例如:
this is an <example> that <needs> to turn into
=> this is an that to turn into
答案 0 :(得分: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);