【发布时间】:2020-10-06 02:26:44
【问题描述】:
我想找到一个正则表达式解决方案来匹配项目编号之后的字符串的一部分,直到找到任何字符,除非它是单词'and'
s = 'this part 123 should be ignored Item Number(s)92349252 and 30239429434, 124029354,345340332, 234325923 hallo 2121124'
如果我特别添加hallo,它会起作用
re.match(r'.*?Item Number\(s\)(.*?)hallo.*$', s).group(1)
'92349252 and 30239429434, 124029354,345340332, 234325923 '
但是我希望它适用于任何字符(包括hallo),除非它是单词and。
【问题讨论】: