Am trying to replace content with empty using this regular expression.
objRegExp.Pattern = "<(?>/?)(?!(p|strong)(>|\s))[^<]+?>"
sHtml = objRegExp.Replace(sHtml, "")
If I test this <(?>/?)(?!(p|strong)(>|\s))[^<]+?> regex on gskinner, it is working fine. But when I place this on Classic ASP page, it is not working.
When I debug error is shown as
Syntax error in regular expression
INPUT:
<h2>Regex testing</h2><br/><p>P Test</p><div>Div Test</div><strong>Strong Test</strong>
EXPECTED OUTPUT:
Regex testing<p>P Test</p>Div Test<strong>Strong Test</strong>
Please suggest, What’s gone wrong here?
VBScript does not support atomic groups (the
(?>/?)construct at the start).See here the feature overview on regular-expression.info. VBScript is using the ECMA flavour.
Remove the atomic group and replace the check for the leading slash
This seems to do the job. See it here on Regexr
Update
OK, I removed too much if you put back
(>|\s)its workingRegexr