REGEX删除被<派克祝辞

本文关键字:派克 删除 REGEX | 更新日期: 2023-09-27 18:09:11

用什么c#正则表达式来替换开始和结束字符之间的所有文本/字符?

例如:

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

REGEX删除被<派克祝辞

我将使用Html解析器如htmllagilitypack来代替Regex

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

但是如果你必须使用Regex

var text = Regex.Replace(html, @"'<.+'>", String.Empty);