簡體   English   中英

如何使用regexp匹配TCL中的括號

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM