Регулярные выражения иногда могут быть просто монструозными. Выглядеть это может крайне запутанно. Сами регэкспы и без того история непростая, а когда это длинный паттерн на несколько десятков знаков, разобрать там что-либо становится не просто.
Но на помощь приходит Python и его стремление сделать нашу жизнь проще!
В функциях регулярок можно после паттерна указывать флаги, один из которых позволяет писать паттерны более свободно. А именно, добавлять пробелы и переносы, которые будут игнорированы. В результате мы можем разбить паттерн на строки и добавить комментов.
Чтобы это сработало нужно добавить флаг re.VERBOSE. Пробелы в паттерне теперь следует указывать явно спец символами.
Согласитесь, что даже с именованными группами а таком виде регэкспа выглядит вполне сносно 😉.
#tricks#regex
Vegan diets can help the environment, but large-scale plant farming can hurt soil, wildlife, and cause pollution. Synthetic fertilizers used in farming can damage oceans and soil. Animal farming done the right way helps soil, supports wildlife, and uses natural manure. Eating animal foods gives important nutrients like B12 and iron that plants don’t provide.
🌿🐄🌎
[Read more]
@googlefactss
#Vegan#Environment#SoilHealth#AnimalFarming#Nutrition#SustainableFarming#EcoFriendly
A single tree, called the Tree of 40 Fruits, holds the record for the most varieties of fruit on one tree. Created by Sam Van Aken, it has 40 different types of stone fruits. These include peaches, plums, apricots, almonds, and cherries. The tree was made using grafting, where branches from different fruit trees are attached to one rootstock. This project shows how diverse fruit can grow on a single tree.
🍑🌳🍒🍎🍏
[Read more]
@googlefactss
#TreeOf40Fruits#Grafting#SamVanAken#FruitVarieties#GuinnessWorldRecords#AmazingNature#SustainableFarming
Kaly Group Funding Update
Kaly Group has raised $379.64K in funding, as of December 19, 2024. This Scottish initiative focuses on sustainable seaweed farming, delivering training and support to local communities while promoting the ecological benefits of kelp cultivation.
#KalyGroup#Funding#SustainableFarming#Seaweed#Ecology#MarineEnvironment#CommunitySupport#Scotland#Kelp#Entrepreneurs
Hussam Saraf set a record for the most species grafted onto a single tree. His tree has 5 different species: plum, apricot, almond, peach, and cherry. The tree was made by grafting branches from these species onto one trunk. This represents diversity and peaceful coexistence, as the fruits symbolize how different cultures can live together.
🌳🍑🍒
[Read more]
@googlefactss
#Grafting#PeacefulCoexistence#HussamSaraf#FiveSpeciesTree#FruitDiversity#GuinnessWorldRecords#AmazingNature#SustainableFarming