in reply to Regular Expression matching question
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?
|
|---|