Iterate through a page headings

For an example using a captured group in the replaceRE function see:

Not sure how you could retrieve the captured group with findRE.

Also there are a few more topics in the forum about your question, look them up perhaps you find something else.