Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
Do not save your drugs for later or share them with another person.
Ensure you complete your dosage as prescribed by a certified healthcare worker.
Play your part to prevent #AntimicrobialResistance.
Dear Healthcare Workers,
Remember that many infections present with similar signs and symptoms. Always maintain a high index of suspicion.
To prevent #AntimicrobialResistance, conduct a test before you treat a patient.
Dear Healthcare Workers,
Remember that many infections present with similar signs and symptoms. Always maintain a high index of suspicion.
To prevent #AntimicrobialResistance, conduct a test before you treat a patient.
#AntimicrobialResistance is a global health issue leading to the ineffectiveness of drugs against the illness they were developed to treat.
Health care practitioners should always conduct a test before prescribing treatment for a patient
Do not save your drugs for later or share them with another person.
Ensure you complete your dosage as prescribed by a healthcare worker.
Play your part to prevent #AntimicrobialResistance.
Do not save your drugs for later or share them with another individual
Complete your dosage as prescribed by a healthcare worker.
Play your part to prevent #AntimicrobialResistance.
#Antimicrobials are not always needed when you are feeling unwell.
Antibiotics should only be prescribed by healthcare professionals after an appropriate diagnostic test.
Be an #AntimicrobialResistance guardian.
#Antimicrobials are not always needed when you are feeling unwell.
Antibiotics should only be prescribed by healthcare professionals after an appropriate diagnostic test.
Be an #AntimicrobialResistance guardian
#Antimicrobials are not always needed when you are feeling unwell.
Antibiotics should only be prescribed by healthcare professionals after an appropriate diagnostic test.
Be an #AntimicrobialResistance guardian
#Antimicrobials are not always needed when you are feeling unwell.
Antibiotics should only be prescribed by healthcare professionals after an appropriate diagnostic test.
Be an #AntimicrobialResistance guardian
The misuse and overuse of #antibiotics💊 & other antimicrobials reduces their effectiveness in treating common infections in animals & humans.
Everyone has a role to play to help fight #AntimicrobialResistance, do your part!
Misuse or overuse of #antibiotics💊 & other antimicrobials can reduce their effectiveness in treating common infections in animals & humans.
Everyone has a role to play to help fight #AntimicrobialResistance, do your part!