Forum Discussion

DaveC_21078's avatar
DaveC_21078
Icon for Altostratus rankAltostratus
Sep 01, 2009

string map is replacing ? with a space

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's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    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