I'm new to regular expressions, but I've already figured out how to parse an block of HTML for links and place those links in an array for use later. What I'd like to do is use one of the replace functions to replace the closing anchor tags with the closing anchor tags plus a superscript number that can be used to match each link to its URL. To do this, I need to increment a variable each time a match is made. The endstate of this will be a "printer-/user-friendly" page that uses footnotes to show a user what the URL of each link on a printed page will go. The problem with printing a web page is that, while links may stand out because of their formatting, you really don't know where they will take you.
Any ideas on incrementing a variable every time a match is made?
Thanks in advance.