我正在尝试针对可能有多个模式实例的字符串匹配模式。我需要分别获得每个实例。re.findall()
应该可以做到,但我不知道我哪里错了。
pattern = re.compile('/review: (http://url.com/(\d+)\s?)+/', re.IGNORECASE)
match = pattern.findall('this is the message. review: http://url.com/123 http://url.com/456')
我希望 'http://url.com/123', http://url.com/456 以及数字123和456成为match
列表中不同的元素。
我也尝试过将正则表达式模式设置为'/review: ((http://url.com/(\d+)\s?)+)/'
,但没有成功。