I am currently writing a tcl/tk script that communicates with an external application. I have succesfully managed to extract a string and process it as required. My issue is that some of these strings are of the format xyz[0:2] and therefore need to be passed to the application as xyz\[0:2\] to stop them being interpreted as commands
I have tried using the following
to substiture the backslashes in. However whenever this variable is used later in the script, even passing it to the application, the new backslash is just interpreted as escaping the square brackets again, returning to the original problem.
Any thoughts?
I have tried using the following
Code:
if [regexp \[.*\] $path] {
set subs1 "\\\["
set subs2 "\\\]"
regsub {\[} $path $subs1 newPath
regsub {\]} $newPath $subs2 $path
}
to substiture the backslashes in. However whenever this variable is used later in the script, even passing it to the application, the new backslash is just interpreted as escaping the square brackets again, returning to the original problem.
Any thoughts?