Re: Simple regex with whitespaces

2006-09-11 Thread John Machin
James Stroud wrote: > Paul McGuire wrote: > > <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>Hello, > >> > >> I cannot figure out a way to find a regular expression that would > >>match one and only one of these two strings: > [clip] > >>Any suggestion ? Thanks a bunch ! >

Re: Simple regex with whitespaces

2006-09-11 Thread James Stroud
Paul McGuire wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > >>Hello, >> >> I cannot figure out a way to find a regular expression that would >>match one and only one of these two strings: [clip] >>Any suggestion ? Thanks a bunch ! >>Mathieu >> > > A pyparsing approach i

Re: Simple regex with whitespaces

2006-09-11 Thread Paul McGuire
<[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Hello, > > I cannot figure out a way to find a regular expression that would > match one and only one of these two strings: > > s1 = ' how are you' > s2 = 'hello world how are you' > > Al

Re: Simple regex with whitespaces

2006-09-10 Thread John Machin
[EMAIL PROTECTED] wrote: > Hello, > > I cannot figure out a way to find a regular expression that would > match one and only one of these two strings: > > s1 = ' how are you' > s2 = 'hello world how are you' > > All I could come up with was: > patt

Re: Simple regex with whitespaces

2006-09-10 Thread James Stroud
[EMAIL PROTECTED] wrote: > Hello, > > I cannot figure out a way to find a regular expression that would > match one and only one of these two strings: > > s1 = ' how are you' > s2 = 'hello world how are you' > > All I could come up with was: > p

Re: Simple regex with whitespaces

2006-09-10 Thread Mark Peters
> Which of course does not work. I cannot express the fact: sentence > have 0 or 1 whitespace, separation of group have two or more > whitespaces. > > Any suggestion ? Thanks a bunch ! How about this: >>> import re >>> s = 'hello world how are you' >>> re.split(r"\s{2,}",s) [''

Simple regex with whitespaces

2006-09-10 Thread mathieu . malaterre
Hello, I cannot figure out a way to find a regular expression that would match one and only one of these two strings: s1 = ' how are you' s2 = 'hello world how are you' All I could come up with was: patt = re.compile('^[ ]*([A-Za-z]+)[ ]+([A-Za