|laziness, impatience, and hubris|
Rematching within a regular expressionby jeff987 (Initiate)
|on May 11, 2012 at 22:11 UTC||Need Help??|
jeff987 has asked for the
wisdom of the Perl Monks concerning the following question:
I am trying to use a regular expression to extract text from a large number of .txt files. I have phrases that demarcate the beginning and ending of the piece of text I want to extract. However these phrases are potentially in other parts of the document as well. The specific problem I am trying to tackle is when the beginning phrase is repeated twice without the ending phrase occurring. This leads me to collect more of the text than I want. Hopefully this specific example will help explain my problem.
When I run this code:
I end up with:
How do I change my regular expression to skip over the second "dog" and end up with $finds = dog bird cat?
Thanks in advance! Please excuse me if I have broken any protocols. I'm quite new to Perl and this is my first time seeking help here.