Python and regex, can't understand why some words are left out of the match

53 views Asked by At
s = ("If I’m not in a hurry, then I should stay. " +
"On the other hand, if I leave, then I can sleep.")
re.findall(r'[Ii]f (.*), then', s)

The output is:

I’m not in a hurry, then I should stay. On the other hand, if I leave

The question is: Why aren't the words "If" and "then" not included in the output?

Something like this:

If I’m not in a hurry, then I should stay. On the other hand, if I leave, then
0

There are 0 answers