Simple regex with whitespaces
mathieu.malaterre at gmail.com
mathieu.malaterre at gmail.com
Sun Sep 10 23:36:44 EDT 2006
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-z]+)$')
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 !
Mathieu
More information about the Python-list
mailing list