lua-users home
lua-l archive

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

> 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 ;

I think here we match empty string and write ITEM
I  recently  read  Hopcroft's  Introduction  in automata theory :). And i
think this is like eNFA. Before read each char we "read" empty string.
To  recognition  it  is  not  important when and how mach time we read that
empty string, but for substitution it is important. I think it have to
be and documented implementation detail.

> 3) The 'a' matches 'a*' and so we print ITEM4) After the last match, but before the second ';' there are zero 'a's so we print ITEM5) 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

>  > =(";a;"):gsub("a-", "ITEM")
> Why is that 'a' still there?
I think "a-" always math only empty string (as short as possible)

For me all this behavior are predictable. May be it is bug. but o