提取脚本标记的正则表达式 [英] Regular Expression for Extracting Script Tags
问题描述
我试图写在C#中的正则表达式来删除所有脚本标记及其中包含的任何
I am trying to write a regular expression in C# to remove all script tags and anything contained within them.
到目前为止,我想出了以下内容: \≤([^:] *?:) script\> [^(\< /≤([^:??] * :) script\>) ?] * \< / script\方式>
,但是这不工作
So far I have come up with the following: \<([^:]*?:)?script\>[^(\</<([^:]*?:)?script\>)]*?\</script\>
, however this does not work.
我要打破它,并解释我的思想在每一节:
I'll break it up and explain my thinking in each section:
\<([^:]*?:)?script\>
在这里,我想指出,这应该得到任何脚本元素,哪怕是带有前缀命名空间,比方说,< A:脚本>< / A:脚本>
我也已将此添加到结束标记
Here I am trying to state that it should get any script element, even if it is prefixed with a namespace, say, <a:script></a:script>.
I have also added this to the closing tag.
[^(\</<([^:]*?:)?script\>)]*?
在这里,我想指出,它应该允许任何标签内包含除< / A:脚本>
,< / SCRIPT>
等
\</script\>
在这里,我指出它应该有一个关闭标签。
Here I am stating that it should have a closing tag.
任何人都可以找出我要去的地方错了。
Can anyone spot where I am going wrong?
推荐答案
使用 HTML敏捷性包的吧。
这篇关于提取脚本标记的正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!