in reply to RE: (tye)Re: Metatag processing (overlapping regions)
in thread Metatag processing (overlapping regions)

And what happens if you want to define an escaped region?

Or say that a \ escapes what would otherwise be a tag?

My recommendation matches tye's. If the problem is going to stay simple then KISS, process each tag with a pass. If it isn't then create a one-pass algorithm where as you pass through the initial string you incrementally create the replaced string. This approach is more complex to set up, but once set up is a lot more flexible.

One approach is to use Parse::RecDescent. There are lots of examples of that around, if you run into trouble then ask questions. Another is to roll your own, for an example of how to do that you could take a look at Why I like functional programming. (Skip to the function at the very end, the problem solved there is much more complex than yours here, and most of the code there is irrelevant to you.)

But trying to do all of this logic with modifying in place is going to be simple insanity to figure out.

  • Comment on RE (tilly) 3: Metatag processing (overlapping regions)