[英]how to use regexp to match a parentheses in TCL
我对使用regexp匹配TCL中的括号有疑问。
例如,我有一个像这样的字符串:
yes, it is (true, and it is fine).
我只想匹配这部分yes, it is (true
,如何匹配?
您可以按照@bobah的建议在字符类中加上括号,
yes, it is [(]true
但是更常见的是逃避它:
yes, it is \(true
但是,如果要转义,请确保您了解必须执行以下操作:
regexp -- "yes, it is \\(true" $subject
或这个:
regexp -- {yes, it is \(true} $subject
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.