Небольшой трик с регулярными выражениями который редко вижу в чужом коде.
Допустим, вам нужно распарсить простой текст и вытащить оттуда пары имя+телефон. Вернуть всё это надо в виде списка словарей. Возьмем очень простой пример текста.
>>> text = '''
>>> Alex:8999123456
>>> Mike:+799987654
>>> Oleg:+344456789
>>> '''
Соответственно, для выделения нужных элементов будем использовать группы. Получится такой паттерн:
(\w+):([\d+]+)
Как мы будем формировать словарь из найденных групп?
>>> import re
>>> results = []
>>> for match in re.finditer(r"(\w+):([\d+]+)", text):
>>> results.append({
>>> "name": match.group(1),
>>> "phone": match.group(2)
>>> })
>>> print(results)
[{'name': 'Alex', 'phone': '8999123456'}, ...]
Можно немного сократить запись используя zip
>>> results = []
>>> for match in re.finditer(r"(\w+):([\d+]+)", text):
>>> results.append(dict(zip(['name', 'phone'], match.groups())))
Но есть способ лучше! Это именованные группы в regex. Можно в паттерне указать имя группы и результат сразу забрать в виде словаря.
>>> for match in re.finditer(r"(?P<name>\w+):(?P<phone>[\d+]+)", text):
>>> results.append(match.groupdict())
То есть всё что я сделал, это добавил в начале группы (внутри сбокочек) такую запись:
(?P<group-name>...)
Теперь найденная группа имеет имя и можно обратиться к ней как к элементу списка
>>> name = match['name']
Либо забрать сразу весь словарь методом groupdict()
>>> match.groupdict()
#tricks#regex
Аромат дня - Guess 1981 Los Angeles (женский) 💖
Свежими, бодрящими цитрусовыми аккордами мандарина и вкусными фруктовыми нотками душистой груши и ярких ягод красной смородины открывается аромат, сплетаясь в «сердце» композиции с роскошными цветочными оттенками медового пиона, изысканного белого жасмина и чарующим апельсиновым цветом ✨
Восточные ноты нежной пудровой ванили, сладкого пралине, чувственного мускуса и элегантные древесные оттенки сливочно-хвойного кедра завершают великолепный женский парфюм Guess 1981 Los Angeles Woman.
СТОИМОСТЬ💵
Guess 1981 Los Angeles, 100 мл – 2 850 руб
#ЖенскиеАроматы
#Guess
⚫️ Больше ароматов Guess и других брендов по запросу
⚫️ Для заказа и по всем вопросам - @originalproduct_new
🎙 INVEST REPORT ANNOUNCE GUESSIT
⚖️ INVEST REPORT project rating 8/10 ⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️⭐️
GUESSIT is an exciting, community-driven game where players buy credits to guess a numeric code. The goal? Crack the safe and win the ever-growing prize pool! Every attempt grows the pot and raises the stakes. But there’s more: an interactive AI Agent guards the safe, securely generates the code, and helps players strategize without revealing the solution. This isn't just a game—it’s a social phenomenon where players come together to share tips, analyze guesses, and compete for glory.
One of the better launches I've seen under these market conditions. Over $2m in volume already.
Project sit now at 8M MC floor and team is waiting when to launch marketing.
Whats more to come?
- Game about to be dropped
- Marketing is about to kick in
- Game viral marketing through TIKTOK
- 2.5X Leverage trading
👉CA: 9PHyv24rtL8RKSnsniZ3G5WwKrChCiDAuMvW3earGr9g
☑️ Follow GUESSIT:
Website: https://guessitsol.ai/
X: https://x.com/guessitonsol
Telegram: https://guessitsol.ai/
TIKTOK: https://www.tiktok.com/@guessitsol
#GUESS#AI#Game
I guessed this word in 3/6 tries.
✏️GRUFF
📅 29.03.2026
🟩🟩⬜️🟧⬜️
⬜️🟩🟧⬜️⬜️
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
Reward: 160 🌟
Can you guess this word❓
PLAY NOW 🔜@DailyPuzzles
#wordle#DailyPuzzles#daily#guess
I guessed this word in 4/6 tries.
✏️ABUSE
📅 27.03.2026
⬜️⬜️⬜️🟧⬜️
⬜️⬜️🟧⬜️⬜️
⬜️🟩🟩⬜️⬜️
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
Reward: 120 🌟
Can you guess this word❓
PLAY NOW 🔜@DailyPuzzles
#wordle#DailyPuzzles#daily#guess
I guessed this word in 5/6 tries.
✏️DALLY
📅 24.03.2026
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
⬜️🟧🟧⬜️⬜️
🟧🟩⬜️⬜️⬜️
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
Reward: 100 🌟
Can you guess this word❓
PLAY NOW 🔜@DailyPuzzles
#wordle#DailyPuzzles#daily#guess
I guessed this word in 6/6 tries
✏️SLINK
📅 20.03.2026
⬜️⬜️⬜️⬜️🟧
⬜️⬜️⬜️⬜️⬜️
🟧⬜️⬜️⬜️🟧
🟩🟩🟧🟧⬜️
🟩🟩🟩🟩⬜️
🟩🟩🟩🟩🟩
Reward: 100 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 3/6 tries
✏️ENEMY
📅 17.03.2026
🟩⬜️🟩⬜️⬜️
⬜️🟧⬜️⬜️🟧
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
⬜️⬜️⬜️⬜️⬜️
Reward: 160 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 5/6 tries
✏️CACHE
📅 16.03.2026
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
🟩⬜️⬜️🟩⬜️
🟩⬜️⬜️⬜️🟧
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
Reward: 120 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 5/6 tries
✏️LABEL
📅 14.03.2026
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
🟩⬜️⬜️🟩⬜️
🟩⬜️⬜️⬜️🟧
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
Reward: 120 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 5/6 tries
✏️SILLY
📅 13.03.2026
⬜️⬜️🟩🟩🟩
⬜️⬜️🟩🟩🟩
⬜️🟩🟩🟩🟩
⬜️🟩🟩🟩🟩
🟩🟩🟩🟩🟩
⬜️⬜️⬜️⬜️⬜️
Reward: 120 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess
I guessed this word in 6/6 tries
✏️CAMEL
📅 12.03.2026
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
⬜️⬜️⬜️🟩⬜️
🟩⬜️⬜️🟩⬜️
🟩🟩🟩🟩🟩
Reward: 100 🌟
Can you guess this word❓
https://t.me/DailyPuzzlesBot?startapp
#wordle#DailyPuzzles#daily#guess