lua-users home
lua-l archive

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


On 29/04/13 17:03, Peter Hickman wrote:
The reading of "a*" is to match zero or more 'a's

So
1) There are zero 'a's before the first ';' so print ITEM
2) The ';' is not an 'a' so just print ;
3) The 'a' matches 'a*' and so we print ITEM
4) After the last match, but before the second ';' there are zero 'a's so we print ITEM
5) The ';' is not an 'a' so just print ;
6) After the last ';' but before the end of the string there are zero 'a's so print ITEM

The only oddity for me is step 4 if my understanding of how this works is correct.

Of course without step 4 you would have what you wanted. To be honest I am mystified by step 4, it looks like a bug to me


Even odder....

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?

Scott