First page Back Continue Last page Overview Image

8.5 Control Structures – switch

[75] [241] switch -nocase -matchvar -indexvar

Make capture groups accessible to switch bodies.

Applicable only to switch -regexp ...

set string "some long complicated message"

switch -matchvar foo -indexvar bar -regexp -- $string {

{\w*(e)\w*} {

puts "match: [lindex $foo 0] with 'e' at [lindex $bar 1 0]"

}

default {

puts "no words containing a letter 'e' at all"

}

}