3 # Copyright (C) 2005-2007, The Perl Foundation.
6 # the following lines re-execute this as a tcl script
7 # the \ at the end of these lines makes them a comment in tcl \
8 use lib qw(languages/tcl/lib tcl/lib lib ../lib ../../lib); # \
12 source lib/test_more.tcl
15 proc regexp_is {pattern string reason} {
16 eval_is "regexp {$pattern} {$string}" 1 $reason
19 proc regexp_isnt {pattern string reason} {
20 eval_is "regexp {$pattern} {$string}" 0 $reason
23 set usage {wrong # args: should be "regexp ?switches? exp string ?matchVar? ?subMatchVar subMatchVar ...?"}
24 eval_is {regexp} $usage {no args}
25 eval_is {regexp a} $usage {one args}
27 eval_is {regexp -bork a b} \
28 {bad switch "-bork": must be -all, -about, -indices, -inline, -expanded, -line, -linestop, -lineanchor, -nocase, -start, or --} \
36 regexp a+b baaabd t1 t2
37 is [list $t1 $t2] {aaab {}} {submatch var but no actual sub match}
40 regexp a(.*)a abbba t1
41 is $t1 {abbba} {submatch with no sub var}
44 regexp a(.*)a abbba t1 t2
45 is [list $t1 $t2] {abbba bbb} {submatch with var}
48 regexp -indices aa(b+)aa aabbbbbbbbaa t1 t2
49 is [list $t1 $t2] {{0 11} {2 9}} -indices
51 # http://www.tcl.tk/man/tcl8.5/TclCmd/re_syntax.htm
53 regexp_is asdf asdf "literal, t"
54 regexp_isnt asdf fdsa "literal, f"
56 regexp_is a* bbb "*, true"
57 regexp_is a* bab "*, true"
58 regexp_is a* baab "*, true"
59 regexp_is a* baaab "*, true"
81 # m,n - restricted to 0, 255
123 # Re may NOT end with \
169 # Interaction of [] and \d: e.g. [a-c\d] vs. [a-c\D]
265 # cperl-indent-level: 4
268 # vim: expandtab shiftwidth=4: