$arg=TEST #### Requested, NOT AVAILABLE psy #;
I have a string above where the # is dynamically generated.
I have to use a function in tcl to do a string replacement.
Basically I need to remove the comma(,) form the above expression and display it as
TEST #### Requested NOT AVAILABLE psy #
Here’s what I did, but it is not working.
regsub -all {"Requested,"} $arg {"Requested"} arg
This is where i referenced the function from:
http://www.tcl.tk/man/tcl8.5/TclCmd/regsub.htm
The problem is your quoting. You are actually checking for the string
"Requested,"(including the quotes), but that isn’t what you want. Try either getting rid of the squiggly-brackets (}) or double quotes ("):If all you need to get rid of is the comma, you can search/replace that (just replace it with the empty string
""):or
As a commenter had mentioned, the latter may be better in the general case, since regular expressions often contain many backslashes (
/) and the{}brackets don’t require massive amounts of distracting extra backslash escapes the same way that""quotes do.