In TCL what is the difference between string "match" and string "equal". They are almost same so I am not able to detect the difference between them.
Asked
Active
Viewed 1,210 times
2 Answers
3
string equal
compares two strings character by character and returns 1 if they both contain the same characters (case sensitive: can be overridden).
string match
compares a string against a glob
-style pattern and returns 1 if the string matches the pattern.
In a degenerate case, a string match
with only non-special characters in the pattern is equivalent to a string equal
.
Documentation: string
Syntax of Tcl string matching:
*
matches a sequence of zero or more characters?
matches a single character[chars]
matches a single character in the set given by chars (^ does not negate; a range can be given as a-z)\x
matches the character x, even if that character is special (one of*?[]\
)

Peter Lewerin
- 13,140
- 1
- 24
- 27
0
already answered in TCL string match vs regexps Regexp are slower than base function. So you should avoid regex for equal check
-
2While it's good advice in general, it has basically nothing to do with this question, since it isn't about regular expression matching. – Peter Lewerin Aug 29 '17 at 04:48