Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
Shipping disruptions strand 8 million kg of #Kenyan tea in #Mombasa as #US-#Israel war with #Iran hits exports
Disruptions to global shipping routes linked to the ongoing war between the United States, Israel, and Iran have left nearly eight million kilograms of tea stranded in warehouses in Mombasa, threatening export earnings and farmer incomes, according to the East Africa Tea Traders Association.
George Omuga, managing director of the association that runs the Mombasa tea auction, told Reuters that losses have been accumulating at roughly $8 million per week since 01 March.
“The current conflict in the Middle East has had a direct impact, a negative impact on this auction,” Omuga said, noting that no tea shipments were currently leaving for Middle Eastern markets, which account for 20–25% of Kenya’s tea exports.
https://x.com/addisstandard/status/2039378986518626404?s=20
News: #Somaliland's #Israel deal could put #Berbera port at risk
#Somaliland says its recognition by Israel could be a boon for its Berbera port. But with missiles flying across the region, it could also be a target.
Berbera port on the Gulf of Aden has been transformed by the #UAE firm #DP_World over the past decade into a state-of-the-art facility on one of the world's busiest trade routes.
Berbera still handles far fewer containers than nearby #Djibouti or #Mombasa, but port traffic was up 30 percent from 2023 to 2025, and recent diplomatic moves could lead to much more.
A deal under negotiation with #Ethiopia, a landlocked neighbour with more than 130 million inhabitants, could see traffic rise by another 80 percent, said port authority director Ali Diriye Ahmed.
Ethiopia did not respond to queries on the subject.
But an alliance with Israel also brings risks, particularly as the US-Israeli attacks on Iran this weekend increase the threat of ........
Read more: https://addisstandard.com/?p=55487