> Yes, but your *. should be .* to work. When you have
Sorry, typo. It is .* in the code!
> % If I do (for example) "p1 p2 p1 p2\n\np1 p2", shouldn't the
> while loop match
> % on 3 instances? If not, what should I use to match each instance?
>
> Now that it's all one big line, you need /g to make it global (more than
> just the first on the line). Time to go back to the Camel book for some
> reading; while regexps can be tricky, you *can* get to the bottom of them!
>
>
> %
> % Again, my goal is to match each instance of /(p1)*anything*(p2)/.
>
> I should think that
>
> undef $/ ;
> ...
> /(p1).*(p2)/g ;
>
> would do it for you.
I would think so too...but that's not the case!
I've tried with /g alone and also with /gs, /gm, and /gms. As long as /s is
one of the modifiers I do match one instance, but in no case do I match
multiple instances. Weird.
Thanks for any additional clues.
dn
ps. Here's the code again (with correct typing this time!):
undef $/;
while (<MYFILE>) {
if(m/(p1).*(p2)/gs
) {
print "match! found $1 and $2.\n";
}
}
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]