Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
🌎 On Ellesmere Island in Canada’s High Arctic, Alert is Earth’s northernmost permanently inhabited settlement. In winter, temperatures can plunge to –40°C, and the sun disappears for months. Fewer than 100 people live here year-round. ✨
#arctic⚡#climate⚡#isolation
👉subscribe Interesting Planet
👉more Channels
🌎 One of the world's most remote settlements is Tristan da Cunha, an island in the South Atlantic Ocean. Home to only about 250 people, it lies 2,400 kilometers from the nearest continent. The island has no airport and is accessible only by a week-long boat journey from South Africa. ✨
#geography⚡#settlements⚡#isolation
👉subscribe Interesting Planet
👉more Channels
La canzone "C'è solo la strada" di Giorgio Gaber invecchia terribilmente bene e dopo il 2020 acquista quasi natura profetica.
#vaporonda#vaporwave#vapourwave#vaporart#seapunk#webpunk#glitch#glitchart#glitchartistscollective#chillwave#aesthetic#vaporwaveaesthetic#vaporwaveaesthetics#malinconia#melancholy#tristezza#sadness#sadboy#lofi#solitudine#loneliness#isolamento#isolation#casa#home#giorgiogaber