<p class="MsoNormal">
<span lang="EN-US">http://www.baidu.com<!--[if gte vml 1]><v:shape id="_x0000_i1027" type="#_x0000_t75" alt="" style='width:19.5pt;height:15pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg" o:href="../Local%20Settings/Temp/%7dB)O@27$~09%7b0VR%7b8FN%7d1HX.jpg"/> </v:shape><![endif]--><![if
!vml]><img width="26" height="20" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg"
v:shapes="_x0000_i1027"><![endif]></span></p>这是我从剪切板中获取的HTML格式化的RTF内容,现在要将非HTML标签从中踢除,正则表达式要怎么写?
解决方案 »
- 如何实现和GRIDVIEW一样的右键 "编辑模板"?
- ajax区没人理,转发到这里求助下. JQUERY AJAX问题
- 用三个panel实现完善项目信息,请给个类似实例!急谢谢了。
- asp.net2.0网络打印的问题
- 大侠来看下,小菜一碟
- 大家连接表的实体类是怎么实现的?
- 在按钮执行服务器端代码前,如何先执行一段JavaScript的程序?而这段JavaScript的程序本身就能阻止发送
- 请问asp与asp.net有何区别
- 我的机不知道为什么不能运行asp.net了
- 求在DataGrid中改变某字段值的简便方法,谢谢!
- 关于自定义控件ashx的引用地址的问题
- brother how to get the path of my file
<span lang="EN-US">http://www.baidu.com<!--[if gte vml 1]><v:shape id="_x0000_i1027" type="#_x0000_t75" alt="" style='width:19.5pt;height:15pt'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg" o:href="../Local%20Settings/Temp/%7dB)O@27$~09%7b0VR%7b8FN%7d1HX.jpg"/> </v:shape><![endif]--><![if
!vml]><img width="26" height="20" src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtml1\01\clip_image001.jpg"
v:shapes="_x0000_i1027"><![endif]></span></p>
你想得到什么
<input type="button" onclick="test()" value="test" />
<script type="text/javascript">
function test()
{
var tmp = document.getElementById("htmlContent").value;
alert(getHTML(tmp));
}
function getHTML(html) {
var div = document.createElement("div");
div.innerHTML = html;
return div.innerText;
}
</script>
<p>...</p><span><o:f>....</o:f></span><otherHTML><o:other></o:other></otherHTML>
现在想去掉<o:xxx .... />若是<o:xxx>....</o:xxx>
就是想得到纯正的HTML。
还是想得到<p>... </p><span> </span> <otherHTML> </otherHTML>
Regex reg = new Regex(@"(?is)<o:[^>]+>.*?</o:[^>]+>");
str = reg.Replace(str, "");
MessageBox.Show(str);
网上说要用到什么平衡组之类的,但例子是只针对Div的:
平衡组的一个最常见的应用就是匹配HTML,下面这个例子可以匹配嵌套的<div>标签:<div[^>]*>[^<>]*(((?'Open'<div[^>]*>)[^<>]*)+((?'-Open'</div>)[^<>]*)+)*(?(Open)(?!))</div>.
能不能帮我改成用于<o:xxx的?注:表达式最后的.不知道是不是半角句号。
<p class=MsoNormal><span lang=EN-US><img width=553 height=415 src="f:\74673d12-ca8a-4fc8-9324-f6d2b0b7268c.jpg" v:shapes="_x0000_i1025"></span></p> <p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p> <p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p> <p class=MsoNormal><span lang=EN-US>32</span><span lang=EN-US style='font-size: 18.0pt'>41</span><span lang=EN-US>231<span style='background:yellow;mso-highlight: yellow'>42314</span></span></p>
结果:<p class=MsoNormal><span lang=EN-US><img width=553 height=415 src="f:\74673d12-ca8a-4fc8-9324-f6d2b0b7268c.jpg" v:shapes="_x0000_i1025"></span></p> <p class=MsoNormal><span lang=EN-US></span></p> <p class=MsoNormal><span lang=EN-US></span></p> <p class=MsoNormal><span lang=EN-US>32</span><span lang=EN-US style='font-size: 18.0pt'>41</span><span lang=EN-US>231<span style='background:yellow;mso-highlight: yellow'>42314</span></span></p>
就是这样,目前不考虑深度嵌套的问题。
Regex reg = new Regex(@"(?is)<o:[^>]+>.*?</o:[^>]+>");
str = reg.Replace(str, "");
MessageBox.Show(str);
这样可以啊