Convert string so that every 'a' between "<bb>...</bb>" is turned into string "bb" and everything between "<U>...</U>" is uppercased.
"aa<bb>aa<U>aa</bb>aa</U>aa" => "aabbbbBBBBAAaa"
Approach problem: I could go first through all </?bb> tags, apply conversions between them and then kill the tags. But that sounds ineffective with longer strings and this is trivialization (sp?) anyways, so I'll just say I want to do this with only one run-through the string, so that the data that's given to processing routine is something like:
"aaaaaaaa", b from offset 2 to 6, U from offset 4 to 8
This where I have a problem; when I apply one conversion, it might invalidate existing offsets inside a string; for example, if I apply the first "b" region, string becomes as following: "aabbbbbbbbaa", causing the 'U' region begin after the 2nd 'b' when it should begin after the 4th 'b'.
I can avoid this sometimes by applying the last conversions first, but if the two regions overlap, this isn't feasible.
You see, with more complicated rules, the real location of 'U' tag becomes quite unpredictable.
What I'd really like would be some sort of magical null-byte that didn't show up on actual representation of string, but hanged around inside the string, moving around like is proper with the character inserts an deletes. And in this spirit I, of course, could add something like '<foo>' to the string temporarily as this hangaround tag, and remove it afterwards, but that's a bit unclean (not to mention dangerous/tricky; what if <foo> already is there?)
Bottom line: if you can think of way to fix the problems with my initial implementation idea or come up with better one for the problem above, one that doesn't iterate through actual tags inside the string many times, I'd be one happy initiate.
In reply to Metatag processing (overlapping regions) by kaatunut
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |