Match First Sequence in Regular Expression?

Roger L. Cauvin roger at
Thu Jan 26 12:14:38 EST 2006

"Christos Georgiou" <tzot at> wrote in message 
news:cf0it11eno1nh0baimee3ec9cohn3u6rv1 at
> On Thu, 26 Jan 2006 18:01:07 +0100, rumours say that "Fredrik Lundh"
> <fredrik at> might have written:
>>Roger L. Cauvin wrote:
>>> Good suggestion.  Here are some "test cases":
>>> "xyz123aaabbab" accept
>>> "xyz123aabbaab" reject
>>> "xayz123aaabab" accept
>>> "xaaayz123abab" reject
>>> "xaaayz123aaabab" accept
>>$ more
> [snip of code]
>>    m ="aaab", string)
> [snip of more code]
>>$ python
>>got    expected
>>accept accept
>>reject reject
>>accept accept
>>reject reject
>>accept accept
> You're right, Fredrik, but we (graciously as a group :) take also notice 
> of
> the other requirements that the OP has provided elsewhere and that are not
> covered by the simple test that he specified.

My fault, guys.  The second test case should be

"xyz123aabbaaab" reject

instead of

"xyz123aabbaab" reject

Fredrik's pattern fails this test case.

Roger L. Cauvin
nospam_roger at (omit the "nospam_" part)
Cauvin, Inc.
Product Management / Market Research

More information about the Python-list mailing list