diff options
author | Sergio Queiroz <sqmedeiros@gmail.com> | 2017-01-04 14:50:41 -0300 |
---|---|---|
committer | Sergio Queiroz <sqmedeiros@gmail.com> | 2017-01-04 14:50:41 -0300 |
commit | 02b61c3bcbda1b42959ecdf23750647f573f58af (patch) | |
tree | ac8dec513542b5937b962c60fc6d53a1b05af45c /examples | |
parent | e0feb1b3a659411d53b231d24929c4b7b4d92431 (diff) | |
download | lpeglabel-02b61c3bcbda1b42959ecdf23750647f573f58af.tar.gz lpeglabel-02b61c3bcbda1b42959ecdf23750647f573f58af.tar.bz2 lpeglabel-02b61c3bcbda1b42959ecdf23750647f573f58af.zip |
Adding to README an example about farthest failure
Diffstat (limited to 'examples')
-rw-r--r-- | examples/farthest.lua | 14 |
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 @@ | |||
1 | local m = require'lpeglabel' | ||
2 | |||
3 | function matchPrint(p, s) | ||
4 | local r, lab, sfail = p:match(s) | ||
5 | print("r: ", r, "lab: ", lab, "sfail: ", sfail) | ||
6 | end | ||
7 | |||
8 | local p = m.P"a"^0 * m.P"b" + m.P"c" | ||
9 | matchPrint(p, "abc") --> r: 3 lab: nil sfail: nil | ||
10 | matchPrint(p, "c") --> r: 2 lab: nil sfail: nil | ||
11 | matchPrint(p, "aac") --> r: nil lab: 0 sfail: c | ||
12 | matchPrint(p, "xxc") --> r: nil lab: 0 sfail: xxc | ||
13 | |||
14 | |||