[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Possible pattern bug
- From: "Liam Devine" <liamdevine@...>
- Date: Sat, 16 Nov 2013 21:22:55 -0000
On 16/11/13 20:59, Michael Savage wrote:
( "[a] [b] c" ):match( "%[(.-)%] c" )
-> "a] [b"
From http://www.lua.org/manual/5.1/manual.html#5.4.1 or
a single character class followed by '-', which also matches 0 or more
repetitions of characters in the class. Unlike '*', these repetition
items will always match the shortest possible sequence;
The shortest possible sequence for the above is "b". Is this a bug?
It is not, as it returns the first match . If you wanted to capture
the last sequence in square brackets you could prefix it with a greedy
( "[a] [b] c" ):match( ".*%[(.-)%] c" )