regexp matching around a wordby kidd (Curate)
|on May 14, 2005 at 02:19 UTC||Need Help??|
kidd has asked for the
wisdom of the Perl Monks concerning the following question:
Hello Monks, im in seek of your wisdom once again.
I have this string:
In this string there are several instances of the word blue. What im trying to do is fetch the text around the words "blue". So i have this regexp:
Basically what it does it finds from 0 to 5 words before the word "blue" and the same after the word "blue". This gives me the next results:
But then I realized that in the first result line a word "blue" appears on the 5 words after the word "blue".
So I thought that maybe I could change the regexp to find the 5 words after the word "blue" in case the word "blue" is in the words around "blue".
Maybe I could give an example, my desired result would be:
What I tried without sucess was this:
I hope you can understand my problem.
Thanks in advanced for any help.
If your a spanish spoken programmer go to my site: Perl en Espaņol