*/*CKGT*0P*\ */*CKGT*ON*\\ */*CKGT*0T*\\
如何删除上面字符串中的反斜杠?字符串的长度会有所不同
答案 0 :(得分: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
答案 1 :(得分: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!
谢谢, Bordoloi先生