lua-users home
lua-l archive

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


>>> ps:gmatch("(%d+)%f[^%d]")
>> When will the above be different from ps:gmatch("%d+") ?
> when a more ethical Lua gets developed, and we get "moderately greedy"
> patterns that consume only a fair share of characters.  :-)

Indeed ;). I was thinking about a more complex pattern for extracting
numbers, which in this case wasn't needed:

ps = "1,22,33,4444,abc123def"
for n in ps:gmatch("%f[%w](%d+)%f[%W]") do
  print(n)
end

This would only extract "standalone" numbers (and not those that are
part of words).

Paul.