Patrick Spence wrote:
        ...
> proc insert_macro { thestring key macro} {
>     regsub -all -- $key $thestring $macro thestring;
>     return "$thestring"
> }

It's not quite clear from your explanation what you really want, and
how you want the & handled.  However, I suspect that 'string map'
would make your life easier, if you are doing direct string mapping.
This would be like:

proc insert_macro {str searchStr replaceStr} {
    return [string map [list $searchStr $replaceStr] $str]
}

string map takes any number of pairs.  This is new since Tcl 8.1,
but the latest stable AOLServer is using 8.3.

Otherwise if you really want to replace something based on a
regular expression, then you probably need to escape the subspec
if it has &'s or \'s in it.

  Jeff Hobbs                     The Tcl Guy
  Senior Developer               http://www.ActiveState.com/
      Tcl Support and Productivity Solutions

Reply via email to