Forum Discussion
Matt_Breedlove_
Jul 17, 2012Nimbostratus
switch glob tcl string match support
Hi All
When using switch -glob, I know it supports square bracket char ranges such as [a-f], but does it support either of these?
Either "a" or "d" or "f"
[a,d,f]
o...
hooleylist
Jul 19, 2012Cirrostratus
I thought I replied to this yesterday. Somehow it got lost in the ether.
switch -glob uses the same pattern matching as string match. string match does not support the {a,d,f} syntax. I think that's for shell syntax only.
You can use [adf] though to match any characters in the character class. For switch you could also use hyphens to take the same action for multiple matches:
switch -glob $letter {
a -
d -
f {
Matched a d or f
}
}
Or:
switch -glob $letter {
[adf] {
Matched a d or f
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects