什么是c#正则表达式来替换开始和结束长矛之间的所有文本/字符?
例如:
this is an <example> that <needs> to turn into
=> this is an that to turn into
Run Code Online (Sandbox Code Playgroud)
而不是正则表达式,我会使用像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;
Run Code Online (Sandbox Code Playgroud)
但是如果你必须使用正则表达式
var text = Regex.Replace(html, @"\<.+\>", String.Empty);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
216 次 |
| 最近记录: |