> -----Original Message-----
> From: David T-G [mailto:[EMAIL PROTECTED]]
> Sent: Monday, July 22, 2002 8:13 PM
> To: perl beginners
> Cc: David Newman
> Subject: Re: regexp matching across newlines
> 
> 
> David --
> 
> ...and then David Newman said...
> % 
> % > Yes, but your *. should be .* to work.  When you have
> % 
> % Sorry, typo. It is .* in the code!
> 
> Ah.  Well, then, there's more...
> 
> 
> % 
> ...
> % > % 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.
> 
> Whoops!  No it won't -- .* is greedy!
> 
> You need something more like
> 
>   undef $/ ;
>   ...
>   /(p1)[^(p2)]*(p2)/g ;
> 
> in order to match p1 and the *first* p2 each time :-)

This does not match on input data like:

   (p1)foo2baz(p2)
   (p1)foo(bar)baz(p2)

See the flaw?

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to