I have a function in my script that's supposed to take in a string of HTML and return the same string with the exception that all the elements shall have been changed to one that is 2 levels higher (ie. h1->h3, h2->h4 etc.). This of cause needs to work independed of casing, and it must not remove attributes, however, I'm not about to use a full html-parser for it either, as it's a fairly simple task, so I figured I'd go about this with regexes. The problem is (me beeing fairly new to vbscript and all) that I don't know how to achieve the desired effect.
What I have currently is this:
Function fiksoverskrifter(html)
Dim regex, matches, match
Set regex = New RegExp
regex.Pattern = "<(/?)h([0-9])(.*?)>"
regex.IgnoreCase = True
regex.Multiline = False
fiksoverskrifter = html
Set matches = regex.Execute(html)
For Each match in matches
Next
Set regex = Nothing
Set matches = Nothing
Set match = Nothing
End Function
What I want inside the For Each
-loop is simply to swap the numbers, however, I'm not sure how to do that (I'm not even sure what properties the match
-object exposes, and I've been unable to find it online).
How should I complete this function?