aboutsummaryrefslogtreecommitdiff
path: root/examples/farthest.lua
diff options
context:
space:
mode:
Diffstat (limited to 'examples/farthest.lua')
-rw-r--r--examples/farthest.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/examples/farthest.lua b/examples/farthest.lua
new file mode 100644
index 0000000..692390f
--- /dev/null
+++ b/examples/farthest.lua
@@ -0,0 +1,14 @@
1local m = require'lpeglabel'
2
3function matchPrint(p, s)
4 local r, lab, sfail = p:match(s)
5 print("r: ", r, "lab: ", lab, "sfail: ", sfail)
6end
7
8local p = m.P"a"^0 * m.P"b" + m.P"c"
9matchPrint(p, "abc") --> r: 3 lab: nil sfail: nil
10matchPrint(p, "c") --> r: 2 lab: nil sfail: nil
11matchPrint(p, "aac") --> r: nil lab: 0 sfail: c
12matchPrint(p, "xxc") --> r: nil lab: 0 sfail: xxc
13
14