lua-users home
lua-l archive

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


Am 29.04.2013 20:20, schrieb Mark Gabby:
> Why does this behave in this way? I would expect the result to be:
> 
> ITEM;ITEMITEMITEM;ITEM 5
> 
>     > > Lua 5.2.2  Copyright (C) 1994-2013 Lua.org, PUC-Rio
>     > >  > =(";a;"):gsub("a-", "ITEM")
>     > >  ITEM;ITEMaITEM;ITEM    4
>     > >
>     > > Why is that 'a' still there?

"a-" matches the shortest string possible so that the rest of the
pattern still matches. An "a-" at the end of the pattern always matches
exactly 0 characters.

Best regards,

David Kolf