我正在尝试从我的字符串中删除以下内容:
细绳:
Snowden (left), whose whereabouts remain unknown, made the extraordinary claim as his father, Lon (right), told US television he intended to travel
我正在使用以下正则表达式:([(].*[)])
,但它是匹配的:
(left), whose whereabouts remain unknown, made the extraordinary claim as his father, Lon (right)
这是有道理的,但不是我想要的。
我能做些什么来解决这个问题?它与贪婪或懒惰有关吗?
编辑:
我正在使用 Python:
paren = re.findall(ur'([(\u0028][^)\u0029]*[)\u0029])', text, re.UNICODE)
if paren is not None:
text = re.sub(s, '', text)
这导致以下输出:
Snowden (), whose whereabouts remain unknown, made the extraordinary claim as his father, Lon (), told US television he intended to travel
但是,当我打印 paren.group(0) 时,我得到“(左)”,这意味着括号包括在内,这是为什么呢?
谢谢。