王超 wrote: > hi, > > I want to match the regular expression from right to left, such as: > > TAG_pattern = re.compile(r"(us::.*) .*(1002|1003).*$") > TAG_pattern.search(line) > > Does the search method support this?
What do you mean match from right to left? If you mean, match an re that is anchored at the end of the string, then sure, $ is supported. If you mean, find the right-most match of several (similar to the rfind method of a string) then no, it is not directly supported. You could use re.findall() and chose the last match but if the matches can overlap this may not give the correct result. Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor