string - TCL 字符串前置

标签 string tcl prepend

只是一个简单但经常需要的操作 - 如何将字符串添加到变量:

set s "world!!!"
prepend s "Hello " #how to accomplish this effectively?
puts $s
#should print "Hello world!!!"

最佳答案

你可以编写一个过程prepend:

proc prepend {s_var txt} {
  upvar 1 $s_var s
  set s "${txt}${s}"
}

这正是您想要的。但我认为通常写起来更简单:

set s "Hello ${s}"

关于string - TCL 字符串前置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10009181/

相关文章:

jquery - 获取新前置元素的属性值

objective-c - 替换字符串中的字符

c# - 如何从字符串中删除字符组合?

java - 如何在java中搜索字符串及其后面的数字

tcl - tcl/expect 中的正则表达式

regex - 正则表达式匹配两个单词之间的所有内容

linux - 如何将 gcc 安装到 RedHat Enterprise 5 虚拟机上?

jquery - 将 .css() 添加到前置的 div

jQuery - 如何将鼠标悬停在使用前置添加的代码上

php - 编程中如何调用 "special characters"的字符串自定义处理?