Hi,
I’m doing a string map and the first ? after ad.imp in the replacement string is being replaced with a space. Strings below. How do I stop that?
string map “adserver/impression/pid=$pid/oid=$oid/rand=$rand/?click ad.imp?pid=$pid&oid=$oid&rand=$rand/?pclk”
Thanks
string map uses glob-style pattern matching which means that ? is a special character meaning “any one character”. If you need to match a literal ? you need to escape it:
string map “adserver/impression/pid=$pid/oid=$oid/rand=$rand/\?click ad.imp\?pid=$pid&oid=$oid&rand=$rand/\?pclk”
The same would be true of * [ and ]
http://www.tcl.tk/man/tcl8.4/TclCmd/string.htm
hoolio
September 1, 2009, 5:58pm
3
Hi David,
I think string match uses glob style matching, but I’m not sure about string map:
% string map “a?c def” abc
abc
% string map “a*c def” abc
abc
% string map “a?c def” a?c
def
% string map “a?c d?f” a?c
d?f
Aaron