简体   繁体   English

如何在tcl中使用正则表达式从单词中删除括号

[英]How to remove brackets from a word using regexp in tcl

Hi I am trying to remove the brackets from a word like NAND[0] and I want the result to be NAND0.嗨,我想从像 NAND[0] 这样的词中删除括号,我希望结果是 NAND0。 How do I code using regexp in Tcl.如何在 Tcl 中使用正则表达式进行编码。

Assuming the data from which you want to strip the brackets is in the variable val and have the transformed data stored in variable result假设要从中去除括号的数据位于变量val ,并将转换后的数据存储在变量result

set result [regsub -all {\[|\]} $val ""]

You can also do你也可以这样做

regsub -all {\[|\]} $val "" result 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM