How to remove the characters "{" and "}" from string after reading it from file using TCL? -


the string:

{ii= 10 } & {jj= 2 } 

i need:

ii= 10 & jj= 2 

i tried: string trim, string replace, lreplace, , not work me.

if have

set x "{ii= 10 } & {jj= 2 }" 

you can do

string map {\{ {} \} {}} $x # -> ii= 10  & jj= 2  

i.e. replace literal left , right brace empty string.

but string looks lot string representation of list, automatically inserted braces preserve whitespace. working list, need

join $x # -> ii= 10  & jj= 2  

using string trim doesn't work since removes characters ends of string:

string trim $x \{\} # -> ii= 10 } & {jj= 2  

the string replace command work in case.

the lreplace command works on list elements, not characters in strings.

documentation: join, lreplace, set, string


Comments