How can i remove style attribute from any tag with regex in 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
solved *
(\sstyle=['""][^'""]+?['""])
objRegExp.Pattern = "/style\s*=\s*(\'|').+(\'|')/i", the starting/and end/iwill be interpreted as part of the pattern so you can remove them./iis accounted for byobjRegExp.IgnoreCase = True'does not need to be escaped and is not going to work for"so you have to indicate them. In VBScript"is escaped by a second pair of bunny ears:"". Your regexp pattern string should be something like:"style\s*=\s*[""'].+[""']"