To remove parentheses from anywhere in a string (URLs are just strings with some format constraints) you should use string map
.
proc removeParens {string} {
# Convert each parenthesis character into an empty string, removing it
string map {( "" ) ""} $string
}
The regsub
command could also be used, but would be slightly overkill for this. The string trim
command won't work easily; that only removes characters from the two ends of the string, not the middle, so you'd need to split it up and join it and so on and that's way too much work if you don't need to do it!
Note that URLs have a syntax for quoting characters that could cause parentheses to still be present in some sense (despite not literally being there); whether this matters to you depends on what other processing you're doing. Generally speaking, it's important to be very careful with any and all URL handling.