Say I have a string like this:
set str "BAT-CAT, DOG,ELEPHANT ,LION & MOUSE-ANT ,MONKEY, DONKEY"
Now I want to get STRING as follows:
"BAT-CAT,DOG,ELEPHANT,LION&MOUSE-ANT,MONKEY,DONKEY"
I am using trim function to remove white space but it is not working kindly suggest any regsub or procedure for same thank you
The best way to remove all spaces from a string is to use string map:
set stripped [string map {" " ""} $originalString]
regsub -all { } $str ""
This will return: BAT-CAT,DOG,ELEPHANT,LION&MOUSE-ANT,MONKEY,DONKEY
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With