On 04/04/2005-04:20PM, lothar wrote: > > how then, do i specify a non-greedy regex > <1st-pat><not-1st-pat>*?<follow-pat> > > that is, such that non-greedy part <not-1st-pat>*? > excludes a match of <1st-pat> >
jet% cat vwre2.py #! /usr/bin/env python import re vwre = re.compile("V[^V]W") vwlre = re.compile("V[^V]WL") if __name__ == "__main__": newdoc = "V1WVVV2WWW" vwli = re.findall(vwre, newdoc) print "vwli[], expect", ['V1W', 'V2W'] print "vwli[], return", vwli newdoc = "V1WLV2WV3WV4WLV5WV6WL" vwlli = re.findall(vwlre, newdoc) print "vwlli[], expect", ['V1WL', 'V4WL', 'V6WL'] print "vwlli[], return", vwlli jet% ./vwre2.py vwli[], expect ['V1W', 'V2W'] vwli[], return ['V1W', 'V2W'] vwlli[], expect ['V1WL', 'V4WL', 'V6WL'] vwlli[], return ['V1WL', 'V4WL', 'V6WL'] -- http://mail.python.org/mailman/listinfo/python-list