我想从括号中检索字符串。以下是正文
Kaminey (英语:(的)(SC)oundrels()HGGG) ASD (SA) DSAD是维沙尔巴德瓦杰,并设有沙希德·卡普尔,普里查普拉和阿莫尔Gupte领先导演了2009年印度雀跃惊悚片(角色)。在孟买地下世界的背景下,Kaminey在一天的过程中跟随一对双胞胎之间的竞争,一对双胞胎口齿不清,另一对双唇结巴。
现在我要从此文本中获取三个字符串
- (英语:(The)(Sc)oundrels()hggg)
- (到)
- (角色)
我曾尝试遵循以下正则表达式
re.compile(r'\(。*?\)')
re.compile(r'/ \(([[^)] +)\)/')
这将与深度为1的括号匹配。
>>> example = 'My email is [email protected]. My name is John. Her email is [email protected] .I am sam'
>>> s = '''Kaminey (English: (The) (Sc)oundrels()hggg) asd (sa) dsad is a 2009 Indian caper thriller film directed by Vishal Bhardwaj and featuring Shahid Kapoor, Priyanka Chopra and Amol Gupte in the lead (roles). Set against the backdrop of the Mumbai underworld, Kaminey follows a rivalry between a pair of twins, one with a lisp and the other with a stutter, over the course of a single day..'''
>>> import re
>>> re.findall(r'\((?:\([^()]*\)|[^()])*\)', s)
['(English: (The) (Sc)oundrels()hggg)', '(sa)', '(roles)']
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句