【发布时间】:2015-03-15 04:56:51
【问题描述】:
我有以下字符串:
(S{4077..4157} (IN{4077..4081} '(,{4157..4158} ,{4157..4158}) (S{4159..4288} (IN{4159..4163} that{4159..4163})'
我要提取S{4077..4157}和,{4157..4158}) (S{4159..4288}模式:
我试过这个正则表达式:
match = re.compile( r',([{[0-9]+..[0-9}]+[)])*[\s]*[(SBAR{][{0-9]+..[0-9}]', re.M|re.I)
for tr in trees:
#tr.draw()
tr1=str(tr)
matchObj = match.findall(s)
if matchObj:
print ("match : ", matchObj)
else:
print ("No match!!")
【问题讨论】:
-
...当你尝试它时发生了什么?
-
有什么逻辑吗?为什么你只想提取这三个?
标签: python regex string expression