lang-bootstrap/06/deps/lpeglabel/examples/farthest.lua
Dawid Sobczak 858fe11666 Fixed some diagnostics warnings
Moved examples to tofix because fixing them is besides the point right
now.
2023-09-19 11:44:13 +01:00

14 lines
397 B
Lua

local m = require'lpeglabel'
function matchPrint(p, s)
local r, lab, sfail = p:match(s)
print("r: ", r, "lab: ", lab, "sfail: ", sfail)
end
local p = m.P"a"^0 * m.P"b" + m.P"c"
matchPrint(p, "abc") --> r: 3 lab: nil sfail: nil
matchPrint(p, "c") --> r: 2 lab: nil sfail: nil
matchPrint(p, "aac") --> r: nil lab: 0 sfail: c
matchPrint(p, "xxc") --> r: nil lab: 0 sfail: xxc