Can't get the right result when using re.findall function on python -
i want match right string regular expressions, can't.
import re str = "<meta apple <meta" \ "we go<meta" \ "goto mac <meta td yiyang ziyou" \ "net<meta aaask zoie go?" \ "<meta " \ "buy mac" r = re.findall("<meta(?!.*<meta).*mac", str, re.s) i think there matched 2 strings, 1 <meta goto mac, <meta buy mac, got last. why? use pycharm 5.0.3, version of python 3.5.1. thank you.
the problem have negative look-ahead operator (?!.*<meta) means match, there must not <meta later in string.
for reason, last <meta string matched, because can satisfy criteria.
Comments
Post a Comment