[Tutor] how to match regular expression from right to left
kent37 at tds.net
Sun Sep 16 17:25:46 CEST 2007
> Thank you. I got the right results with re.findall('(us::.*?);', line).
> I used these codes before:
> >>> TAG_pattern = re.compile(r"(us::.*?)")
> >>> TAG_pattern.findall(line)
> and got the unwanted results 'us::'
That is because .*? will match the empty string. You have to put the ;
after it to force the match to extend.
More information about the Tutor