Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
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 '

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"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 >

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"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 >> "

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"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]

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"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

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"Fredrik Lundh" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Roger L. Cauvin wrote: > >> > $ python test.py >> > gotexpected >> > --- >> > accept accept >> > reject reject >> > accept ac

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
"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