Match First Sequence in Regular Expression?
tzot at sil-tec.gr
Thu Jan 26 12:11:03 EST 2006
On Thu, 26 Jan 2006 18:01:07 +0100, rumours say that "Fredrik Lundh"
<fredrik at pythonware.com> 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 test.py
[snip of code]
> m = re.search("aaab", string)
[snip of more code]
>$ python test.py
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.
The code above works for "aaaab" too, which the OP has already ruled out,
and it doesn't work for "aaa".
TZOTZIOY, I speak England very best.
please stop spamming us."
More information about the Python-list