switch

switch ?-option ...? string ?pattern body ...? ?default body?

Runs the body of the first pattern that matches the string. A body of - uses the body of the next pattern. The patterns and bodies can be one list in braces.

Options

Option What it does
-exact The pattern equals the string (the default).
-glob A glob pattern.
-regexp A regular expression.
-integer Tcl 9.1 only: the pattern and the string are the same integer, such as 16 and 0x10. A value that is not an integer is an error.
-nocase Matches letters with no case.
-- The end of the options, for a string that starts with -.

Examples

A click on an example runs it in the shell of the page.

Facts