Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
📢#Ebola Travel Advisory
⛔Avoid all but essential travel to UGANDA
🤒Avoid contact with obviously sick persons/#EVD suspected cases
📞Call 6232 (free of charge) if you have recently returned from Uganda within the past 21 days & feel symptoms of #EVD
🔗
https://ncdc.gov.ng/news/423/public-health-advisory-following-declaration-of-ebola-virus-disease-outbreak-in-uganda
The risk of importation of the #EbolaVirusDisease into Nigeria is HIGH.
Healthcare workers & the general public are urged to maintain a high index of suspicion.
📜Read our public health advisory for measures to prevent the importation of #EVD:
https://ncdc.gov.ng/news/423/public-health-advisory-following-declaration-of-ebola-virus-disease-outbreak-in-uganda
Based on available data, the overall risk of importation of the #EbolaVirusDisease and the impact on the health of Nigerians has been assessed as HIGH.
📜Read our public health advisory for measures to prevent the importation of #EVD:
https://ncdc.gov.ng/news/423/public-health-advisory-following-declaration-of-ebola-virus-disease-outbreak-in-uganda