Say, a text file have many $start-$end
pairs, and within each pair there are some text. I want Perl to find-and-replace all $pattern
s with the $start-$end
pairs; if the $pattern
lies out of the pair, then don't replace it. eg for text:
xx START xx bingo xx bingo xx END xx bingo xx START xx bingo xx END bingo
There might be newlines anywhere in the text (not shown here); $pattern
may appear multiple times within a pair. Expected result is:
xx START xx okyes xx okyes xx END xx bingo xx START xx okyes xx END bingo
The job seems straightforward but I just do not figure out a Perl regex to do it. Can anyone help with this?