On 5/17/2013 5:01 PM, Stuart wrote:
>
> Greetings,
>
> I need to process strings like
> ddXaXD@@K@@LB\b@wHPJB\c@{HPJBHc@pH`NB|b@
>
> This string has \ and { so I can't do:
>
> set str {ddXaXD@@K@@LB\b@wHPJB\c@{HPJBHc@pH`NB|b@} cuz that
> will complain about having an extra {
>
This is only an issue when you treat it as a command like when entering
it in a shell or sourcing a file. If you read it as a data file, I
doubt it will be an issue. In any case, string map can help:
% set a {ddXaXD@@K@@LB\b@wHPJBc@\{HPJBHc@pH`NB|b@}
ddXaXD@@K@@LB\b@wHPJBc@\{HPJBHc@pH`NB|b@
% set b [string map {\\ \\\\ \{ \\\{ \} \\\}} $a]
ddXaXD@@K@@LB\\b@wHPJBc@\\\{HPJBHc@pH`NB|b@
% lindex $b 0
ddXaXD@@K@@LB\b@wHPJBc@\{HPJBHc@pH`NB|b@
Similarly, you can include [ and ] in the map.
DrS