: '''string match''' ''?'''''-nocase'''''? pattern string'' See if ''pattern'' matches ''string''; 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. Compare '''[string equal]''' which compares entire strings or parts of strings but NOT expressions. For the two strings to match, their contents must be identical except that the following special sequences may appear in ''pattern'': * '''*''' Matches any sequence of characters in ''string'', including a null string. * '''?''' Matches any single character in ''string''. * '''[['''''chars''''']]''' Matches any character in the set given by ''chars''. If a sequence of the form ''x-y'' appears in ''chars'', then any character between ''x'' and ''y'', inclusive, will match. When used with '''-nocase''', the end points of the range are converted to lower case first. Whereas {[[A-z]]} matches '_' when matching case-sensitively ('_' falls between the 'Z' and 'a'), with '''-nocase''' this is considered like {[[A-Za-z]]} (and probably what was meant in the first place). * '''\'''''x'' Matches the single character ''x''. This provides a way of avoiding the special interpretation of the characters '''*?[[]]\''' 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 [http://sourceforge.net/tracker/index.php?func=detail&aid=219233&group_id=10894&atid=110894]). <> [LV] Does '''string match''' use the same code as [glob] for this? No. ---- ====== set hin [open "/tmp/sample.txt" "r"] set data [read $hin] close $hin if [ string match -nocase "*test*" $data ] { puts "Found test" } else { puts "Did not find test" } ====== <> ---- **See also** * [glob] * [string] <> Tcl syntax | Command | String Processing