Match First Sequence in Regular Expression?

Roger L. Cauvin roger at deadspam.com
Thu Jan 26 12:21:03 EST 2006


"Christos Georgiou" <tzot at sil-tec.gr> wrote in message 
news:9m0it1l6vdl26jbsrsjqm9og7su7tir314 at 4ax.com...
> On Thu, 26 Jan 2006 17:09:18 GMT, rumours say that "Roger L. Cauvin"
> <roger at deadspam.com> might have written:
>
>>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
>
> Here I object to either you or your need for a regular expression.  You 
> see,
> before the "aaa" in your second test case, you have an "arbitrary sequence
> of characters", so your requirements are met.

Well, thank you for your efforts so far, Christos.

My purpose is to determine whether it's possible to do this using regular 
expressions, since my application is already architected around 
configuration files that use regular expressions.  It may not be the best 
architecture, but I still don't know the answer to my question.  Is it 
*possible* to fulfill my requirements with regular expressions, even if it's 
not the best way to do it?

The requirements are not met by your regular expression, since by definition 
the "arbitrary sequence of characters" stops once the sequences of a's and 
b's starts.

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