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

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -