Tcl’s string match Command
Having matched a single line, it is no longer possible to automatically break it up into pieces stored in the array expect_out. Tcl does, however, offer a standalone version of both the regular expression and glob pattern matchers.
Glob pattern matching is explicitly done using the string match command. The command follows the format:
string match pattern string
The string replaces the implicit reference to the input buffer in an expect command. The command returns 1 if there is a match or 0 if there is no match. For example:
if [string match "f*b*" "foobar"] {
puts "match"
} else {
puts "no match"
}
The switch command (demonstrated on page 131) is a little more like the expect command. It supports multiple patterns and actions, but like "string match“, switch uses an explicit string. Neither switch nor "string match" support the ^ and $ anchors.