What's the difference in this "string match"ing ... - TCL
This is a discussion on What's the difference in this "string match"ing ... - TCL ; 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 "*\\" ...
-
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
-
Re: What's the difference in this "string match"ing ...
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
-
Re: What's the difference in this "string match"ing ...
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
Similar Threads
-
By Application Development in forum TCL
Replies: 1
Last Post: 05-16-2007, 01:50 PM
-
By Application Development in forum Theory
Replies: 2
Last Post: 03-21-2007, 02:36 AM
-
By Application Development in forum XML SOAP
Replies: 1
Last Post: 06-15-2006, 10:22 AM
-
By Application Development in forum JDBC JAVA
Replies: 5
Last Post: 11-17-2005, 04:54 PM