there is a word "welcome[world]"
output should be "welcome\[world\]
i am using regsub to add backslash "\" in place where ever i find square brackets (open or close)..
But i am not getting it... pls help out..
set a {welcome[world]}
set d [regsub -all "(?q)\[" "$a" /\[]
x='welcome[world]'
echo $x | sed 's/\[\|\]/\\&/g'
thanks. can we do the same in tcl expect script.. pls help
Yoda
4
set a {welcome[world]}
regsub -all {\[} $a {\\[} a
regsub -all {\]} $a {\\]} d
puts $d
can we do it in a single line???
Yoda
6
set a {welcome[world]}
regsub -all (\\\[|\\\]) $a {\\\1} a
puts $a