What I am looking for is something that will turn:
So I want the '-' in the replacement string to be conditional on whether the match uses n or s. This is really being done for a coordinate pairing, but if this is doable, an easier example might help make it more approachable.
I can do it in two steps, by first getting all the matching data into an array, then parsing it, assembling it into strings for a simpler replace on the second pass.
If the conditional replacement is not possible, what is the fastest simple string replacement function in php? Once I have the array of matches, I could simply setup a simple string replacement with no additional pattern matching if it was faster. ie "34s" to "-34". For an idea of scope, I would be doing this on many pages that have about 1-2 small screens of text.