"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> Roger L. Cauvin wrote:
>
>> Good suggestion.  Here are some "test cases":
>>
>> "xyz123aaabbab" accept
>> "xyz123aabbaab" reject
>> "xayz123aaabab" accept
>> "xaaayz123abab" reject
>> "xaaayz123aaabab" accept
>
> $ more test.py
>
> import re
>
> print "got    expected"
> print "------ --------"
>
> testsuite = (
>    ("xyz123aaabbab", "accept"),
>    ("xyz123aabbaab", "reject"),
>    ("xayz123aaabab", "accept"),
>    ("xaaayz123abab", "reject"),
>    ("xaaayz123aaabab", "accept"),
>    )
>
> for string, result in testsuite:
>    m = re.search("aaab", string)
>    if m:
>        print "accept",
>    else:
>        print "reject",
>    print result
>
>
> $ python test.py
> got    expected
> ---------------
> accept accept
> reject reject
> accept accept
> reject reject
> accept accept

Thanks, but the second test case I listed contained a typo.  It should have 
contained a sequence of three of the letter 'a'.  The test cases should be:

"xyz123aaabbab" accept
"xyz123aabbaaab" reject
"xayz123aaabab" accept
"xaaayz123abab" reject
"xaaayz123aaabab" accept

Your pattern fails the second test.

-- 
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

Reply via email to