Match First Sequence in Regular Expression?

Roger L. Cauvin roger at
Thu Jan 26 15:09:54 CET 2006

Say I have some string that begins with an arbitrary sequence of characters 
and then alternates repeating the letters 'a' and 'b' any number of times, 


I'm looking for a regular expression that matches the first, and only the 
first, sequence of the letter 'a', and only if the length of the sequence is 
exactly 3.

Does such a regular expression exist?  If so, any ideas as to what it could 

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

More information about the Python-list mailing list