Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
Here are some ways to keep your food safe from rodents⬇️
✅Store your food in tightly covered containers
✅Clean your environments regularly
✅Put rodent repellents around your food store
✅Seal all cracks, gaps, or holes in your homes to prevent entry of rodents
#STOPLassaFever
Rats and mice constantly urinate & defaecate, contaminating every surface they touch
Keep your homes & communities clean to prevent direct or indirect contact with rats
➡️Properly dispose of waste from your homes
➡️Do not defecate in open areas
➡️Sweep your floors regularly, removing crumbs or food remnants
#STOPLassaFever
Not all fevers are malaria!
Report early to a healthcare facility when experiencing #LassaFever-associated symptoms.
Early symptoms of #LassaFever include fever, body weakness, sore throat, muscle & chest pain, nausea, vomiting, diarrhoea, cough & abdominal pain.
#STOPLassaFever
Do NOT eat food or drink water contaminated with the urine, faeces, saliva, or blood of rats.
Food safety is key in the prevention of #LassaFever:
✅Store all foods properly in tightly closed containers
✅Ensure proper hygiene when preparing & eating food
#STOPLassaFever
Food safety is key in the prevention of infectious diseases like #LassaFever.
Maintain these safety measures :
✅Store all foods properly in tightly closed containers
✅Ensure proper hygiene in the preparation & consumption of food
#STOPLassaFever
Preventing #LassaFever starts with simple habits!
Remember: 20 seconds of regular handwashing with soap and water can save lives🧼
Let's keep our hands clean and our loved ones safe.
#STOPLassaFever#HandHygiene
🛑 Lassa Fever is highly infectious!
Your hands can carry more than you think — keep them clean to stay safe.
🧼 Wash regularly with soap under running water.
💪 Protect yourself. Protect others.
#LassaFever#HygieneIsKey#NCDCNigeria#StopLassaFever