"Tim Chase" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> Sorry for the confusion. The correct pattern should reject >> all strings except those in which the first sequence of the >> letter 'a' that is followed by the letter 'b' has a length of >> exactly three. > > Ah...a little more clear. > > r = re.compile("[^a]*a{3}b+(a+b*)*") > matches = [s for s in listOfStringsToTest if r.match(s)]
Wow, I like it, but it allows some strings it shouldn't. For example: "xyz123aabbaaab" (It skips over the two-letter sequence of 'a' and matches 'bbaaab'.) -- Roger L. Cauvin [EMAIL PROTECTED] (omit the "nospam_" part) Cauvin, Inc. Product Management / Market Research http://www.cauvin-inc.com -- http://mail.python.org/mailman/listinfo/python-list