Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
From Bush to Trump to Biden, US imperialism against Venezuela has remained a bipartisan affair. VA writer Andreína Chávez's column traces this continuity, from sanctions to coup efforts and beyond.
Read the full column here 👉🏼https://shorturl.at/B8Vdw
#DonaldTrump#sanctions#thesubversivetruth#vacolumn
📝OPINION | VA writer Andreína Chávez examines Venezuela's communes and grassroots democracy just in time for Sunday’s "National Popular Consultation."
“If you speak to a Venezuelan engaged in grassroots organizing, you’ll find that to them democracy is about much more than counting ballots or electing politicians, and they reject foreign meddling as a matter of principle. True democracy demands a deep commitment to democratizing a country’s political and economic system, ensuring that people have control over the structures and resources that shape their lives.”
🔗Read the full opinion piece here:https://shorturl.at/MPLV3
#demcoracy#grassrootsdemocracy#communes#elections#popularvote#fyp#TheSubversiveTruth