in reply to Regular Expression matching question

Just an addendum to what tye had said, in case someone who hasn't read Death to Dot Star! wanders in here.

The first alternative doesn't fail. It matches zero or more occurrences of 'ab' -- and, in fact, after the first 'a' in $text, there are exactly zero occurrences of 'ab'. So it matches.

Technically, it does look for as many matches as possible (it's greedy), but finding none, it's satisfied to match, successfully, none.

Tricky, eh?

  • Comment on RE: Regular Expression matching question