2024-09-24 22:21:01 发布
网友
我想用Python编写一个正则表达式,它将给出tr(“”)中包含的所有字符串。在
例如
str = 'According to some, dreams express tr("profound aspects of personality")' and 'tr("Foulkes 184"), though others disagree.'
所以我想要弦乐“人格的深刻方面”和“福克斯184”
有人能帮我吗?在
不需要向后/向前看,^{}中的一个简单组就足够了:
> s = 'According to some, dreams express tr("profound aspects of personality") "and" tr("Foulkes 184"), though others disagree.' > re.findall(r'tr\("(.*?)"\)', s) ['profound aspects of personality', 'Foulkes 184']
演示:https://regex101.com/r/xgG9AO/5
来自findall文档:
findall
If one or more groups are present in the pattern, return a list of groups.
不需要向后/向前看,^{} 中的一个简单组就足够了:
演示:https://regex101.com/r/xgG9AO/5
来自
findall
文档:相关问题 更多 >
编程相关推荐