Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
🚗✨ Introducing the stunning Pagani Utopia Roadster! 🌟
This masterpiece trades its traditional roof for a removable panel featuring a sleek glass insert. 🪟 For those who prefer a classic touch, there’s an alternative fabric top that neatly stores in its own case. 🎒
With no need for extra reinforcement, the Utopia's inherent strength shines through in this exquisite design. 💪
Under the hood, this beauty packs a powerful punch with an 864-hp V12 engine from Mercedes-AMG! 🔥💨
Get ready to own this automotive marvel for a cool €3.1 million! 💰
#PaganiUtopia#Roadster#Supercar#Auto#CarEnthusiast#DreamCar#ExoticCars#Pagani
🚙✨For Sale: Brabus 900 XLP!✨🚙
Get ready to own a masterpiece! This exclusive pickup, built on the Mercedes-AMG G 63 platform, boasts a staggering 900 horsepower and only 10 units produced! 🚀
📍Mileage: 3,375 km
💰Price: Nearly $1 million
Under the hood, it features a custom-built engine based on the stock V8, with an increased displacement of 4.5 liters, custom turbocharging, and upgraded components for unmatched performance! 🔥
#Brabus900XLP#LuxuryCars#ForSale#SuperPickup#CarEnthusiast#ExoticCars#MercedesAMG#DreamCar#Auto
🚗💨Unleash the Beast: 1600 HP Lamborghini Aventador SVJ!🦙🔥
For those who crave power and performance, Underground Racing Motors is offering a jaw-dropping 1600-horsepower Lamborghini Aventador SVJ for just $1.7 million!💰✨
Originally launched over six years ago, the Aventador SVJ boasts a naturally aspirated 6.5L V12 engine producing 770 HP and 720 Nm of torque. But with the magic of twin-turbocharging and expert tuning, this beast can roar up to an astonishing 1600 HP when fueled with race gas! 🏁💥 On regular gasoline, it still impresses with 1250 HP!
#Lamborghini#AventadorSVJ#UndergroundRacing#Supercar#CarEnthusiast#LuxuryCars#TurboPower#Hypercar#DreamCar#Auto
🚗✨For Sale: Aston Martin Vanquish!✨🚗
This stunning grand tourer isn't just any car; it was featured in a promotional photoshoot for the James Bond film "Die Another Day" starring Pierce Brosnan! 🌟
🔹Power: 460 HP
🔹Mileage: Over 60,000 km
🔹Price: Up to $100,000
Don't miss your chance to own a piece of cinematic history! 🎬💎
#AstonMartin#Vanquish#JamesBond#DieAnotherDay#LuxuryCars#CarForSale#BondCar#DreamCar#Auto
🏎 Get your hands on a piece of history! 🌟
Rare Lamborghini Countach LP400 up for auction! Previously owned by musician Rod Stewart.
Only around 150 LP400 Countach models were ever produced by Lamborghini, featuring a 3.9-liter V12 engine with 370 horsepower. Rod Stewart was the proud first owner of this incredible car, purchasing it in Australia during his tours and then bringing it back to the UK.
💲 Price: $520,000 💲
⏳ Only one day left until the end of the auction! ⏳
#Lamborghini#Countach#LP400#RodStewart#RareCar#MusicianOwned#Auction#DreamCar#MuscleCar#Legendary#CollectorCar