|Do you know where your variables are?|
supported by linked substrings.
Seems to me you are looking for a complex solution when a simple one will do.
In order to mark your substrings, you have to know where they start and end|length.
If you simply unpack the string into an array on those same boundaries, you can edit the individual elements to your hearts content, and when you pack/join them back together, you will have exactly the same effect as your linked substrings without the overhead of all the behind-the-scenes jiggery pockery required to make the latter work.
It's simple. And I like simple :)
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.