I can get the string of my interest using regex, but how do I replace it with a character substituted in the capture?
I want to remove the >
character from inside any html attribute, or replace it with >
.
Sample original string
<html>
<head></head>
<body>
<div sometag="abc>def" onclick="myfn()" class='xyz'>
Dear {@CustomerName},
blah blah blah
</div></body>
</html>
Desired result
<html>
<head></head>
<body>
<div sometag="abc>def" onclick="myfn()" class='xyz'>
Dear {@CustomerName},
blah blah blah
</div></body>
</html>
I'm using the following regex pattern and replacement
Pattern: \s\w+\s*=\s*(['"])[^\1]+?\1
Replacement: -- don't know! what should I use? --
This is my vb.net
code (just in case if it helps)
Dim reAttr As New Regex("\s\w+\s*=\s*(['""])[^\1]+?\1", RegexOptions.Singleline)
result = reAttr.Replace(text, Replace("$&", ">", ""))