C# 如何从包含HTML标识符的字符串中解析文本?
我的网页包含文本区域,其中包含HTML。例如,下面是一个文本示例:C# 如何从包含HTML标识符的字符串中解析文本?,c#,C#,我的网页包含文本区域,其中包含HTML。例如,下面是一个文本示例: var a = "some text follows<p><p>Give the following test text:</p> <pre>abc {<br /> int size;<br /> String name;<br /> Test ( String name, int size ) {<br />
var a = "some text follows<p><p>Give the following test text:</p>
<pre>abc {<br /> int size;<br /> String name;<br /> Test ( String name, int size ) {<br /> this.name = name;<br /> this.size = size;<br /> }<br>"
"some text follows<p><p>Give the following test text:</p>
<pre>abc {<br /> int size;<br /> String name;<br /> Test ( String name, int size ) {<br /> this.name = name;<br /> this.size = size;<br /> }<br>"
var a=“一些文本如下给出以下测试文本:
var a = "some text follows<p><p>Give the following test text:</p>"
var newString = Regex.Replace(a, @"<(.|\n)*?>", string.Empty);
abc{
int size;
字符串名;
测试(字符串名,int size){
this.name=name;
this.size=size;
}
“
我想在删除HTML后,用上面的文本为我的网页设置元描述
有人知道我如何从文本中删除HTML吗?我不需要任何花哨的东西。甚至删除包括尖括号在内的所有内容都可以吗?这可能会有帮助:
some text followsGive the following test text:
使用
或:
测试:
可能重复的可能重复的可能重复的向下投票人你能在这里指定向下投票的原因吗。这说明是有意义的。因为这不是错误的解决方案,海报规定,
我不需要任何花哨的东西。也许甚至只需删除括号内的所有东西,包括尖括号就可以了
...
string html = "your html text";
string result = System.Security.SecurityElement.Escape(html);
var a = "some text follows<p><p>Give the following test text:</p>
<pre>abc {<br /> int size;<br /> String name;<br /> Test ( String name, int size ) {<br /> this.name = name;<br /> this.size = size;<br /> }<br>"
"some text follows<p><p>Give the following test text:</p>
<pre>abc {<br /> int size;<br /> String name;<br /> Test ( String name, int size ) {<br /> this.name = name;<br /> this.size = size;<br /> }<br>"