Only `replace` is regex-based. I doubt that the other functions require much resources. So there's still just one regex. But yes, it turned out more complex XPath-wise. I was attempting to avoid regexes, but ended up with this solution. This solution handles `@src`es without fragment identifiers, but then again, I think all `@src`es are required to have fragment identifiers anyway. So we could replace the XPaths in the XSLT with the original XPath (feel free to do so if you think it's more readable), but I doubt there's much performance to gain from it.

The biggest performance gain in this PR isn't actually the XSLT though (although I think that helped as well). The most important improvement is extracting the `px:mediaoverlay-rearrange` out from the `p:for-each` so that it is only invoked once instead of once for each content document.