[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Pattern question
- From: Peter Cawley <lua@...>
- Date: Tue, 23 Apr 2013 12:14:57 +0100
On Tue, Apr 23, 2013 at 11:02 AM, Bernd Eggink <firstname.lastname@example.org> 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.