vbscript - Replace with regex keeping part of the pattern -
in example below, how preserve part of pattern? pattern search must include closing tag </h3>
spans elsewhere must not targeted.
example: remove </span>
</span> text </h3>
:
regex.pattern = "</span>[^>]*</h3>" hr2 = regex.replace(hr2,"[^>]*</h3>") '<- not work
you need set capturing group , use reference in replacement pattern.
regex.pattern = "</span>([^>]*)</h3>" hr2 = regex.replace(hr2,"$1</h3>")
or
regex.pattern = "</span>([^>]*</h3>)" hr2 = regex.replace(hr2,"$1")
Comments
Post a Comment