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
be?
--
Roger L. Cauvin
[EMAIL PROTECTED] (omit the "nospam_" part)
Cauvin, Inc.
Product Management
quot;"
The correct pattern should reject the string:
'xyz123aabbaaab'
since the length of the first sequence of the letter 'a' is 2. Yours
accepts it, right?
--
Roger L. Cauvin
[EMAIL PROTECTED] (omit the "nospam_" part)
Cauvin, Inc.
Product Management / Market Research
http://www.cauvin-inc.com
--
http://mail.python.org/mailman/listinfo/python-list
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
[EMAIL PROTECTED] (omit the "nospam_" part)
Cauvin, Inc.
Product Management / Market Research
http://www.cauvin-inc.com
--
http://mail.python.org/mailman/listinfo/python-list
"Sybren Stuvel" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Roger L. Cauvin enlightened us with:
>> I'm looking for a regular expression that matches the first, and
>> only the first, sequence of the letter 'a', and only if the le
7;b' has a length of
>> exactly three.
>
> Ah...a little more clear.
>
> r = re.compile("[^a]*a{3}b+(a+b*)*")
> matches = [s for s in listOfStringsToTest if r.match(s)]
Wow, I like it, but it allows some strings it shouldn't. For example:
"xyz123aabba
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 14:09:54 GMT, rumours say that "Roger L. Cauvin"
> <[EMAIL PROTECTED]> might have written:
>
>>Say I have some string that begins with an arbitrary
is ensures that no "a"s come before the first 3x"a" and nothing but "b"
> and "a" follows it.
Anchoring may be the key here, but this pattern rejects
"xayz123aaabab"
which it should accept, since the 'a' between the '
"Peter Hansen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> 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
>
files so that the code
doesn't have to change to add or change patterns. Before throwing up my
hands and re-architecting, I wanted to see if regexps would handle the job
(they have in every case but one).
--
Roger L. Cauvin
[EMAIL PROTECTED] (omit the "nospam_" part)
Cauvin, Inc.
Product Management / Market Research
http://www.cauvin-inc.com
--
http://mail.python.org/mailman/listinfo/python-list
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Roger L. Cauvin wrote:
>
>> Good suggestion. Here are some "test cases":
>>
>> "xyz123aaabbab" accept
>> "xyz123aabbaab" reject
>> "
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 16:41:08 GMT, rumours say that "Roger L. Cauvin"
> <[EMAIL PROTECTED]> might have written:
>
>>Good suggestion. Here are some "test cases&qu
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 16:26:57 GMT, rumours say that "Roger L. Cauvin"
> <[EMAIL PROTECTED]> might have written:
>
>>"Christos Georgiou" <[EMAIL PROTECTED]
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 18:01:07 +0100, rumours say that "Fredrik Lundh"
> <[EMAIL PROTECTED]> might have written:
>
>>Roger L. Cauvin wrote:
>>
>>> Good s
"Christos Georgiou" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> On Thu, 26 Jan 2006 17:09:18 GMT, rumours say that "Roger L. Cauvin"
> <[EMAIL PROTECTED]> might have written:
>
>>Thanks, but the second test case I listed con
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Roger L. Cauvin wrote:
>
>> > $ python test.py
>> > gotexpected
>> > ---
>> > accept accept
>> > reject reject
>> > accept ac
"Tim Chase" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> The below seems to pass all the tests you threw at it (taking the modified
> 2nd test into consideration)
>
> One other test that occurs to me would be
>
> "xyz123aaabbaaabab"
>
> where you have "aaab" in there twice.
Good
16 matches
Mail list logo