В настоящее время я использую следующее выражение:
Код: Выделить всё
r"Chapter.+?(?:(Jan(uary)?|Feb(ruary)?|Mar(ch)?|Apr(il)?|May|June?|July?|Aug(ust)?|Sep(t(ember)?)?|Oct(ober)?|Nov(ember)?|Dec(ember)?)[ ](3[01]|[12][0-9]|[0][1-9]|[1-9])[,][ ](20\d{2}))"
Код: Выделить всё
updates = re.findall(regex, text)
Код: Выделить всё
"text text Chapter 5 text text text November, 12 2024. Text Text"
Код: Выделить всё
('November', '', '', '', '', '', '', '', '', 'ember', '', '12', '2024')
Подробнее здесь: https://stackoverflow.com/questions/792 ... -in-python
Мобильная версия