|
Posted by Steve on 10/25/07 14:18
"Erwin Moller"
<Since_humans_read_this_I_am_spammed_too_much@spamyourself.com> wrote in
message news:47205dcb$0$234$e4fe514c@news.xs4all.nl...
> Erwin Moller wrote:
>> Steve wrote:
>
>> So where gives
>> /a[^b]*b/
>> gives a different result than
>> /a[^b]*?/
>>
>
> should be:
> Can you give an example where
> /a[^b]*b/
> differs from:
> /a[^b]*?b/
> of course.
>
> Sloppy typing. Still the same coffee problem. ;-)
ahhh...the damned coffee. :)
it is interpreted differently in different engines. in preg, however, what
you think you're saying is NOT what you're saying.
'aabb' may be a string. your pattern should return three matches. 1) aab, 2)
ab and 3) aabb. this is because of greed inherent in your statement - which
is what the op wanted to know about anyway. using this:
/a[^b]*?b/
keeps the greed at bay. essentially, find an 'a' and any character until you
hit ONE 'b'. so, the above would have two matches...'aab' and 'ab'. it's all
about setting the marker in the preg engine. from that spot, the next set of
matching will begin. you're throwing yours down the street, when all you
needed to do was slide the mug down the bar counter.
no big deal? try it with preg_replace. ;^)
as for my mood? it's pretty consistent. okham's razor would have it that
more likely, two days ago, there were several people saying stupid things.
being consistent, i correct stupid things being said. but, you own your
perspective. see things how you will.
[Back to original message]
|