Match First Sequence in Regular Expression?

Roger L. Cauvin roger at deadspam.com
Thu Jan 26 10:25:54 EST 2006


"Alex Martelli" <aleax at mail.comcast.net> wrote in message 
news:1h9reyq.z7u4ziv8itblN%aleax at mail.comcast.net...
> Tim Chase <python.list at tim.thechases.com> wrote:
>   ...
>> I'm not quite sure what your intent here is, as the
>> resulting find would obviously be "aaa", of length 3.
>
> But that would also match 'aaaa'; I think he wants negative loobehind
> and lookahead assertions around the 'aaa' part.  But then there's the
> spec about matching only if the sequence is the first occurrence of
> 'a's, so maybe he wants '$[^a]*' instead of the lookbehind (and maybe
> parentheses around the 'aaa' to somehow 'match' is specially?).
>
> It's definitely not very clear what exactly the intent is, no...

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

-- 
Roger L. Cauvin
nospam_roger at cauvin.org (omit the "nospam_" part)
Cauvin, Inc.
Product Management / Market Research
http://www.cauvin-inc.com





More information about the Python-list mailing list