I was referring to the :substitute command, which can use submatch() if need be, but usually is not necessary.
Entering :h :s<Enter> at the command line invokes the help for :substitute. :s is usually employed, being the shortest abbreviation of :substitute vim recognizes
There is an associated function substitute(), which works almost identically to :substitute
You really need to read the help chapters usr_27.txt and pattern.txt (:h usr_27 and :h pattern), I cannot possibly give a brief overview of vim's pattern matching and manipulating ability.
Largely I correct ocr-ed texts and convert them to .txt, .html and .epub. The 2 :s command string I supplied is literally all I ever need to produce the Page No. anchors and within Index links (occasionally I may need to use a minor modification of the pattern). But I do this early in the conversion process, when it is simple to differentiate links from anchors. You have left yours until much later, so your pattern will be more complex, but the general principles still apply.