lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Apr 23, 2013 at 11:02 AM, Bernd Eggink <monoped@sudrala.de> wrote:
> Hi experts,
>
> can anybody explain the following:
>
>     s = "/one/two/three"
>     print(s:match("/.-$"))   --> /one/two/three
>
> Shouldn't the result be "/three"? To me it seems clear that "three" is the
> shortest character sequence between '/' and the end of the string.

String patterns have one overarching goal: find the first match.

The ".-" element has a local goal of finding the shortest match, but
this goal is less important than the first-match goal.