There's more than one way to do things | |
PerlMonks |
Substitution with matching nested boundary conditionsby redhotpenguin (Deacon) |
on Jan 24, 2008 at 22:00 UTC ( [id://664150]=perlquestion: print w/replies, xml ) | Need Help?? |
redhotpenguin has asked for the wisdom of the Perl Monks concerning the following question: Monks, I'm trying to solve a difficult (for me at least) regex substitution problem. I think part of the issue is I am trying to use a regex where a short parser implementation would be more appropriate, but I'm Lazy, and hoping that I can coerce Perl's regex engine into doing the work for me. Onto the problem at hand (please ignore whitespace inconsistencies in the content).
The regex I have in this post is one of many variations that I've tried, but this content test case seems to foil all of them. I've used use re 'debug' to look at the inner goodness of what's going on with the regex, but I am coming up empty. In short, I'm trying to replace all instances of zimam nested between foo and bar, with zoomzam. Strange names, but I've boiled the bigger problem down to a test case here that fails. Here's the current output.
And the expected output
Any ideas? (some whitespace formatting is incorrect, please ignore it)
Back to
Seekers of Perl Wisdom
|
|