Determine whether pattern matches string, returning return 1 if it does, 0 if it doesn't. If -nocase is specified, then the pattern attempts to match against the string in a case insensitive manner.
string equal compares strings literally, but string match matches interprets a pattern expression and matches a string against that.
For the two strings to match, their contents must be identical except that the following special sequences may appear in pattern:
Beware that the parsing of strings inside grouping [] is not particularly robust -- neither the manual, the tests nor the code takes pains to specify how to interpret combinations of []*?- inside brackets. If you need a character class which includes any of these special characters, you are probably better off with a [regexp. (see also [L1 ]).
string match does not use the same code as glob
string match *test* "this test is" ;# -> true
to match a single left bracket, the match pattern should be a backslash followed by a left bracket so that string match sees the left bracket as a literal character. One possibility is to place the backslash and left bracket in curly quotes so that Tcl leaves them alone:
string match {\[} {[}
Alternatively, the backslash could be preceded by a backslash and the left bracket could be preceded by a backslash:
string match \\\[ \[
A pattern ending in a backslash doesn't match a string ending in a backslash. Bug?
string match a\\ a\\ # -> 0