2017-02-20 53 views

回答

0

string map命令被設計用於這種任務的:

set inputString {*/*CKGT*0P*\ */*CKGT*ON*\\ */*CKGT*0T*\\} 
# */ # This line is just to stop the StackOverflow syntax highlighter from being silly 

set removed [string map {\\ ""} $inputString] 
puts $removed 
0

一個簡單的代碼段,以驗證:

set a {*/*CKGT*0P*\ */*CKGT*ON*\\ */*CKGT*0T*\\} 
puts $a 
regsub -all {\\} $a {} b 
puts $b 

輸出:

tclsh test2 
*/*CKGT*0P*\ */*CKGT*ON*\\ */*CKGT*0T*\\ 
*/*CKGT*0P* */*CKGT*ON* */*CKGT*0T* 

BING!

謝謝, Mr. Bordoloi