lua-users home
lua-l archive

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


Hello,

Here is an example (gmatch.lua):

=============
local line = ";x;"

local idx = 1;

for value in string.gmatch(line, '[^;]*;?') do
  print(idx .. " value: " .. value)
  idx = idx + 1
end
============

lua -v
Lua 5.3.3  Copyright (C) 1994-2016 Lua.org, PUC-Rio

lua /tmp/gmatch.lua
1 value: ;
2 value: x;


============

lua -v
Lua 5.3.0  Copyright (C) 1994-2015 Lua.org, PUC-Rio

lua ./gmatch.lua
1 value: ;
2 value: x;
3 value:

============

As I don't see that this has been changed / fixed in the bug-list [1],
I expect that this is bug in 5.3.3.

Perl regex behavior is compatible with 5.3.0


$x =~ /[^;]*;?/g
$VAR1 = ';';
$VAR2 = 'x;';
$VAR3 = '';


[1] https://www.lua.org/bugs.html

Thanks!

WBR,
Ivan Baidakou aka basiliscos