我有一段文字:
文本-.text1 -.text2
我只想用虚张声势来提取单词[],用-提取出的单词。
对于这个例子,我只想要文本,而不需要-.text1和-.text2。
泰!
发布于 2013-02-26 20:57:03
假设您正在使用的语言或库支持查找,下面的操作应该有效:
(?<!-\.)\[[^\]]*\]解释:
(?<!-\.) # fail if the previous characters are '-.'
\[ # match a literal '['
[^\]]* # match any number of characters that are not ']'
\] # match a literal ']'示例:http://www.rubular.com/r/HqdR3tZy9R
https://stackoverflow.com/questions/15099066
复制相似问题