Match First Sequence in Regular Expression?

Peter Hansen peter at engcorp.com
Thu Jan 26 11:34:00 EST 2006


Roger L. Cauvin wrote:
> Sorry for the confusion.  The correct pattern should reject all strings 
> except those in which the first sequence of the letter 'a' that is followed 
> by the letter 'b' has a length of exactly three.
> 
> Hope that's clearer . . . .

Examples are a *really* good way to clarify ambiguous or complex 
requirements.  In fact, when made executable they're called "test cases" 
:-), and supplying a few of those (showing input values and expected 
output values) would help, not only to clarify your goals for the 
humans, but also to let the proposed solutions easily be tested.

(After all, are you going to just trust that whatever you are handed 
here is correctly implemented, and based on a perfect understanding of 
your apparently unclear requirements?)

-Peter




More information about the Python-list mailing list