fixed bug in disasm engine
[k8lst.git] / samples / rex.st
blobb4a98105b3bdccd9e225225449e236df2904bfb5
2  coded by Ketmar // Vampire Avalon (psyc://ketmar.no-ip.org/~Ketmar)
3  Understanding is not required. Only obedience.
5  This program is free software. It comes without any warranty, to
6  the extent permitted by applicable law. You can redistribute it
7  and/or modify it under the terms of the Do What The Fuck You Want
8  To Public License, Version 2, as published by Sam Hocevar. See
9  http://sam.zoy.org/wtfpl/COPYING for more details.
11 Requires [ rex ]
14 SimpleRegExp extend [
15 showCaptures [
16   (rexStr, ' | ', string, ' |') printNl.
17   ('start=', matchStart, '; end=', matchEnd) printNl.
18   1 to: captures size do: [:m |
19     ' cpt #' print. m print. '=' print. (self captureAt: m) printNl.
20   ].
21   '----' printNl.
26 {[:rm |
27    rm := SimpleRegExp new: '([a-b])+(c).*'.
28    (rm matchFor: 'abcd') printNl. rm showCaptures.
29    (rm matchFor: 'dabcd') printNl. rm showCaptures.
30  ] value.
31  [:rm |
32    rm := SimpleRegExp new: '^([a-b])+(c).*$'.
33    (rm matchFor: 'abcd') printNl. rm showCaptures.
34    (rm matchFor: 'dabcd') printNl. rm showCaptures.
35  ] value.
36  [:rm |
37    rm := SimpleRegExp new: '^([a-b])+(c)$'.
38    (rm matchFor: 'abc') printNl. rm showCaptures.
39    (rm matchFor: 'abcd') printNl. rm showCaptures.
40    (rm matchFor: 'dabcd') printNl. rm showCaptures.
41  ] value.
42  [:rm |
43    rm := SimpleRegExp new: '([a-b])+?.'.
44    (rm matchFor: 'abcd') printNl. rm showCaptures.
45    (rm matchFor: 'dabcd') printNl. rm showCaptures.
46  ] value.
47  [:rm |
48    rm := SimpleRegExp new: '([a-b])+.'.
49    (rm matchFor: 'abcd') printNl. rm showCaptures.
50    (rm matchFor: 'dabcd') printNl. rm showCaptures.
51  ] value.