Python und Regex können nicht verstehen, warum einige Wörter aus der Übereinstimmung ausgeschlossen werdenPython

Python-Programme
Anonymous
 Python und Regex können nicht verstehen, warum einige Wörter aus der Übereinstimmung ausgeschlossen werden

Post by Anonymous »

Code: Select all

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)
Die Ausgabe ist:

Code: Select all

I’m not in a hurry, then I should stay. On the other hand, if I leave
Die Frage ist: Warum sind die Wörter „Wenn“ und „Dann“ nicht in der Ausgabe enthalten?
Etwas in der Art:

Code: Select all

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

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post