|
|
 |
 |
 |
 |
TCL(Tool Command Language) Scripting
|
 |
 |
 |
 |
 |
 |
 |
 |
What's the difference in this "string match"ing ...
Hello, I traced down a problem I can not understand. Why is the following different? (perhabs the question is foolish or the answer is the easiest to find, but ...) % string match {*\\} "a\\" 1 % string match "*\\" "a\\" 0 Thanks for any hint! Martin Lemburg Siemens Automation and Drives - UGS PLM Software
MartinLemburg@UGS schrieb: > Hello, > I traced down a problem I can not understand. > Why is the following different? (perhabs the question is foolish or > the answer is the easiest to find, but ...) > % string match {*\\} "a\\" > 1 > % string match "*\\" "a\\" > 0 > Thanks for any hint!
The man page for string match states: \x Matches the single character x. This provides a way of avoiding the special interpretation of the characters *?[]\ in pattern. In your first example, string match substitutes the \\ with a single \, in the second example it is already substituted by the parser and string match gets a single \, which it interprets strangely. Michael
MartinLemburg@UGS wrote: > Hello, > I traced down a problem I can not understand. > Why is the following different? (perhabs the question is foolish or > the answer is the easiest to find, but ...) > % string match {*\\} "a\\" > 1 > % string match "*\\" "a\\" > 0 > Thanks for any hint!
here's a hint set a {*\\} set b "*\\" puts "length of a = [string length $a]" puts "length of b = [string length $b]" puts "a contains <$a>" puts "b contains <$b>" Bruce
|
 |
 |
 |
 |
|