Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
Somaliland After Recognition : Interview with Dr. Mohamed Hagi. Watch.
https://borkena.com/2026/01/02/somaliland-after-recognition-interview-with-dr-mohamed-hagi/#Somaliland#SomalilandRecognition#Israel
Israel Officially Recognizes The Republic Of Somaliland. Read more.
https://borkena.com/2025/12/26/israel-officially-recognize-the-republic-of-somaliland/#Israel#Somaliland#SomalilandRecognition
Legal and Historical Basis for the Recognition of the Republic of Somaliland. Read more.
https://borkena.com/2026/04/23/somaliland-legal-and-historical-basis-for-recognition-of-the-republic/#Somaliland#Somalia#politics#Somalilandrecognition
The Horn of Africa Stands at the Edge: Somaliland’s Recognition, Port Politics, and the Gathering Storm of Global Power. Read more.
https://borkena.com/2025/12/30/horn-of-africa-stands-at-the-edge-somalilands-recognition-port-politics-and-the-gathering-storm-of-global-power/#HornofAfrica#SomalilandRecognition#UNSC#Israel
politics
Somaliland and the Evolution of Diplomatic Engagement After 34 Years of Isolation. Read.
https://borkena.com/2026/01/01/somaliland-and-the-evolution-of-diplomatic-engagement-after-34-years-of-isolation/#SomalilandRecognition#Somaliland#Diplomacy