EX of hard way:
switch -regexp -- "StrInG" {
[sS][Tt][Rr][Ii][Nn][gG] { puts "Found string using upper/lower string
sqare braces"}
}
Should be able to use regular expressions '-nocase' option instead and
do something like
regexp -nocase {string} StrInG inside the switch statement??????? HOW?
>I'm trying to create a switch statement using -regexp option and need
>-nocase option for regexp enabled.
>
>switch -regexp -- "StrInG" {
> [sS][Tt][Rr][Ii][Nn][gG] { puts "Found string using upper/lower string
>sqare braces"}
>}
>
>Should be able to use regular expressions '-nocase' option instead and
>do something like
>regexp -nocase {string} StrInG inside the switch statement??????? HOW?
set str "StRiNg"
switch -regexp -- [string tolower $str] {
string {puts "found a string"}
}
regexps have built-in option handling, so just do:
switch -regexp -- $string {
"(?i)string" { ... }
However, it might be a little faster and easier to do just:
switch -exact -- [string tolower $string] {
"string" { ... }
--
Jeff Hobbs The Tcl Guy
Senior Developer http://www.ActiveState.com/
Tcl Support and Productivity Solutions
http://www.ActiveState.com/Products/ASPN_Tcl/