"gnari" <> wrote:
> "Ben Morrow" <> wrote in message
> news:c20fqs$frg$...
> > "gnari" <> wrote:
> > >
> > > ditto here: / (?<=turkey shoot).*?(turkey shoot)/
> >
> > Except that what you actually mean is
> >
> > / (?<= turkey\ shoot .*? ) turkey\ shoot /x
>
> Exept that I actually do not mean this
>
> > which unfortunately doesn't work, so some other method must be
> > employed.
> which is why I did not suggest it
>
> the OP wanted to capture the second occurence
The OP wanted to *match* the second occurence.
> $_='turkey shoot1lkajslkjalsturkey shoot2sdsdfsdturkey shoot3khkj';
> print "[$1:$2]\n" if /(?<=turkey shoot).*?(turkey shoot)(\d)/;
> prints
> [turkey shoot:2]
>
> so what is the problem ?
What's the point in using (?<=) then?
perl -le'$,="|"; print "turkey shoot1 turkey shoot2 turkey shoot3"
=~ /turkey\ shoot.*?(turkey\ shoot)(\d)/'
turkey shoot|2
I was assuming the reason for using (?<=) was so that the pattern could
be used as s/(?<= turkey\ shoot .*? ) turkey\ shoot/foo/x to replace the
second occurence. Using /(?<=turkey\ shoot).*? turkey\ shoot/x will
replace more than desired.
Ben
--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
/Alcestis/) [ flame, and falls out of sight. ]