in reply to Re: pattern matching
in thread pattern matching

As I mention above in my update the .+? is wrong. Consider
<!-- record --> Blah 1 <!-- eorecord --> <h1>Html crap</h1> <!-- record --><!-- eorecord --> <!-- record --> Blah 2 <!-- eorecord -->
Using the .+? we will get only two records out of the file. Using .*? we would get the correct number, three.

Still I think its a bit funny (but not surprising) how similer our posts are... :-)

Yves / DeMerphq
--
When to use Prototypes?

Replies are listed 'Best First'.
Re: Re: Re: pattern matching
by andye (Curate) on Jan 17, 2002 at 15:34 UTC
    Well, I guess you're right, if you'd rather have a successful (blank) pattern match than a failed match. And I guess the web page could concievably contain a blank entry, so that makes sense.

    But in the original context, we're only trying to match one record anyway, so if the match fails then $1 will contain '', and if you use .*? and the match succeeds then $1 will contain '', so I'm not sure it makes any difference. ;)

    andy.