Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
'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 / Market Research http://www.cauvin-inc.com -- http

Re: Match First Sequence in Regular Expression?

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

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 length of the sequence is exactly 3. Your request

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
. 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: xyz123aabbaaab (It skips over the two-letter sequence of 'a' and matches 'bbaaab'.) -- Roger L. Cauvin [EMAIL PROTECTED] (omit

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 sequence of characters and then alternates repeating

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
accept, since the 'a' between the 'x' and the 'y' is not directly followed by the letter 'b'. -- 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
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 followed by the letter 'b' has a length of exactly three

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
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 xayz123aaabab accept xaaayz123abab reject xaaayz123aaabab accept $ more test.py import re print got

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: xyz123aaabbab accept xyz123aabbaab reject xayz123aaabab accept

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] wrote in message news:[EMAIL PROTECTED] On Thu, 26 Jan 2006 14:09:54 GMT

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 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 17:09:18 GMT, rumours say that Roger L. Cauvin [EMAIL PROTECTED] might have written: Thanks, but the second test case I listed contained a typo. It should have contained a sequence of three

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 accept reject reject accept accept Thanks, but the second test case I listed contained a typo

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
Michael Spencer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Roger L. Cauvin wrote: xyz123aaabbab accept xyz123aabbaaab reject xayz123aaabab accept xaaayz123abab reject xaaayz123aaabab accept This passes your tests. I haven't closely followed the thread for other

Re: Match First Sequence in Regular Expression?

2006-01-26 Thread Roger L. Cauvin
. ^([^b]|((?!a)b))*aaab+[ab]*$ Looks good, although I've been unable to find a good explanation of the negative lookbehind construct (?. How does it work? -- Roger L. Cauvin [EMAIL PROTECTED] (omit the nospam_ part) Cauvin, Inc. Product Management / Market Research http://www.cauvin-inc.com

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: Michael Spencer [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] Roger L. Cauvin wrote: xyz123aaabbab accept xyz123aabbaaab reject xayz123aaabab accept xaaayz123abab reject xaaayz123aaabab