Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 在asp中删除带有正则表达式的样式属性_Regex_String_Asp Classic_Vbscript - Fatal编程技术网

Regex 在asp中删除带有正则表达式的样式属性

Regex 在asp中删除带有正则表达式的样式属性,regex,string,asp-classic,vbscript,Regex,String,Asp Classic,Vbscript,如何在asp中使用正则表达式从任何标记中删除样式属性 from: <div style="margin-top:10px;">test</div> to: <div>test</div> Set objRegExp = New regexp objRegExp.Pattern = "/style\s*=\s*(\'|').+(\'|')/i" objRegExp.IgnoreCase = True objRegExp.Global =

如何在asp中使用正则表达式从任何标记中删除样式属性

from:

<div style="margin-top:10px;">test</div>

to:

<div>test</div>



Set objRegExp = New regexp
objRegExp.Pattern = "/style\s*=\s*(\'|').+(\'|')/i"
objRegExp.IgnoreCase = True
objRegExp.Global = True
Set resp = objRegExp.Execute(strWordHTML)
For Each respItem In resp
    strWordHTML= replace(strWordHTML,respItem.Value,"")
Next
Set resp = Nothing
Set objRegExp = Nothing

不使用正则表达式,也没有经过测试,但类似的东西应该可以工作

str = "<div style=""margin-top:10px;"">test</div>"
start = InStr(str, "style")
first = InStr(start, str, """")
second = InStr(first, str, """")

result = Mid(str, 1, start - 1) + Mid(str, second + 1)
str=“测试”
开始=仪表(str,“样式”)
first=InStr(开始,str,“”)
第二个=仪表(第一个,str,“”)
结果=中间(str,1,start-1)+中间(str,second+1)

只是尝试修改代码。但是它不起作用。在
objRegExp.Pattern=“/style\s*=\s*(\''124;').+(\''124')/i”
中,开始的
//code>和结束的
/i
将被解释为模式的一部分,以便您可以删除它们
/i
objRegExp.IgnoreCase=True
解释,正如oracle认证专家所说,请查看您的引号<代码>“
不需要转义,也不适用于
,因此您必须指出它们。在VBScript
中,第二对兔子耳朵转义:
。您的regexp模式字符串应该是这样的:
“style\s*=\s*[“”].+[“”].
若要转义引号,我认为您必须使用双引号。
str = "<div style=""margin-top:10px;"">test</div>"
start = InStr(str, "style")
first = InStr(start, str, """")
second = InStr(first, str, """")

result = Mid(str, 1, start - 1) + Mid(str, second + 1)
 dim result = Regex.Replace(HtmlText, "style[^>]*", "")