"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 16:41:08 GMT, rumours say that "Roger L. Cauvin"
> <[EMAIL PROTECTED]> might have written:
>
>>Good suggestion.  Here are some "test cases":
>>
>>"xyz123aaabbab" accept
>>"xyz123aabbaab" reject
>>"xayz123aaabab" accept
>>"xaaayz123abab" reject
>>"xaaayz123aaabab" accept
>
> Applying my last regex to your test cases:
>
>>>> r.match("xyz123aaabbab")
> <_sre.SRE_Match object at 0x00B47F60>
>>>> r.match("xyz123aabbaab")
>>>> r.match("xayz123aaabab")
> <_sre.SRE_Match object at 0x00B50020>
>>>> r.match("xaaayz123abab")
>>>> r.match("xaaayz123aaabab")
> <_sre.SRE_Match object at 0x00B47F60>
>>>> print r.pattern
> ^(?:.*?[^a])?(a{3})(?:b[ab]*)?$
>
> You should also remember to check the (match_object).start(1) to verify 
> that
> it matches the "aaa" you want.

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