tcl - Explain regsub invocations -
regsub -all "\\\\033" $cmd "\033" cmd [regsub -all "\\\\c" $cmd "" cmd] regsub -all "\\\\$i" $cmd [lindex $exp_out $i] cmd can explain meaning of these 3 statements? 3 different statements.
regsub -all "\\\\033" $cmd "\033" cmd
this replaces instances of backslash followed 033 ascii esc character. reads string process cmd variable , writes variable.
[regsub -all "\\\\c" $cmd "" cmd]
this replaces instances of backslash followed c empty string (effectively deleting it). updates cmd variable. substitutes calling context number of substitutions performed.
regsub -all "\\\\$i" $cmd [lindex $exp_out $i] cmd
this one's bit more complex. particular numeric index, stored in i variable, replaces instances of backslash followed index i'th element (counting 0) of list in exp_out. updates cmd variable.
Comments
Post a Comment