Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个关于使用正则表达式匹配 TCL 中的括号的问题。
例如我有一个这样的字符串:
yes, it is (true, and it is fine).
我就是想配这部分yes, it is (true,怎么配?
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