% set text "Some arbitrary text which might include \$ or {"
Some arbitrary text which might include $ or {
% regexp -inline -all -- {\S+} $text
Some arbitrary text which might include {$} or \{
% set str 66.70.7.154
66.70.7.154
% regexp "(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})\.(\[0-9]{1,3})" $str all f
irst second third fourth
1
% puts "$all \n $first \n $second \n $third \n $fourth \n"
66.70.7.154
66
70
7
154
% puts "$all\n$first\n$second\n$third\n$fourth\n"
66.70.7.154
66
70
7
154
% set string "0377.255.255.255"
0377.255.255.255
% regexp {^\d+\.\d+\.\d+\.\d+$} $string
1
% regexp {^\d+\.\d+\.\d+\.\d+$} $string a b c d
1
% puts "$a,$b,$c,$d"
0377.255.255.255,,,
% puts "$a"
0377.255.255.255
% set word "foo"
foo
% regexp {(foo|bar)} match zzz
0
% regexp {(foo|bar)} match foo
0
% regexp {(foo|bar)} foo
1
% set word "foo"
foo
% set result [regexp {(foo|bar)} $word match zzz]
1
% set match
foo
% set zzz
foo
% set result [regexp {(foo|bar)} $word match]
1
% set match
foo
% set str " sjkhf sdhj "
sjkhf sdhj
% regexp {^ +.* +$} $str match
1
% set match
sjkhf sdhj
% set rest [regexp {^ +.* +$} $str match]
1
1
% regexp {abc$} dabcd
0
% regexp {\d} dabcd
0
% regexp {\d} 123
1
% regexp {\d} "123 abc"
1
% regexp {\d} "123 abc" num
1
% set num
1
% regexp {\d} "323 abc" num
1
% set num
3
% regexp {\d+} "123 abc" num
1
% set num
123
% regexp {\d+} "323d 33 abc" num
1
% set num
323
% regexp {\w+} "123 abc" num
1
% set num
123
% regexp {\w+} "a1234 abc" num
1
% set num
a1234
%