TGTGInsighttelegram intelligenceLIVE / telegram public index
← Python Заметки

TGINSIGHT SIMILAR POSTS

Најди сличен содржај

Изворен канал @pythonotes · Post #146 · 16 сеп.

Функция sub в regex может принимать функцию в качестве аргумента repl. 📄 Из документации: If repl is a function, it is called for every non-overlapping occurrence of pattern. The function takes a single match object argument, and returns the replacement string. То есть для каждого совпадения будет вызвана функция для вычисления замены вместо замены на одну и ту же строку для всех совпадений. Иными словами, для замены разных совпадений на разные строки не потребуется запускать re.sub() много раз для каждой строки замены. Достаточно определить функцию, которая вернёт строку для каждого из совпадений. Описание слишком запутанное🤔, давайте лучше рассмотрим на простом примере: Создаем карту замены. То есть какие строки на какие требуется менять. remap = { 'раз': '1', 'два': '2', 'три': '3', 'четыре': '4', 'пять': '5', } Пишем функцию поиска строки для замены. Единственным аргументом будет объект re.Match. Используя данные этого объекта мы вычисляем замену on-the-fly! def get_str(match: re.Match): word = match.group(1) return remap.get(word.lower()) or word Пример текста. text = '''Раз Два Три Четыре Пять Вместе будем мы считать Пять Четыре Три Два Раз Мы считать научим вас ''' Теперь запускаем re.sub и вместо строки замены (repl) подаём имя функции. (Данный паттерн ищет отдельные слова в тексте) >>> print(re.sub(r'(\w+)', get_str, text)) 1 2 3 4 5 Вместе будем мы считать 5 4 3 2 1 Мы считать научим вас Думаю, достаточно наглядно 🤓 #libs#regex

Hashtags

Резултати

Пронајдени 18 слични објави

Пребарај: #epl

当前筛选 #epl清除筛选
ESPN FC

@BorussiaDortmund · Post #61387 · 03.05.2026 г., 13:46

Man UTD 🆚 Liverpool | Lineups ⏰ 14:30 GMT 🏟️ Old Trafford 📍 Manchester #EPL

Hashtags

Reinrein

@reinseele1 · Post #321 · 24.11.2024 г., 12:13

Начинаем плей-офф European Pro League Season 21 с победы против Passion UA 😠 Продолжим 25 ноября в 19:00 по МСК против победителя пары NAVI Junior vs Level UP. #Dota2#EPL

Hashtags

Reinrein

@reinseele1 · Post #298 · 15.11.2024 г., 20:43

Спишь? А у нас второй матч группового этапа EPL S21. Подключаемся на самое сладкое 👇 ✨RU | ✨EN #Dota2#EPL

Hashtags

Reinrein

@reinseele1 · Post #288 · 12.11.2024 г., 14:19

Врываемся в групповой этап European Pro League Season 21. Первый противник — Dragon Esports Club. ✨ RU: https://www.twitch.tv/epldota_ru2 ✨ EN: https://www.twitch.tv/epldota_en2 #Dota2#EPL

Hashtags

TONlines – News

@tonlines · Post #7241 · 16.05.2025 г., 14:14

Fanton EN: Friday EPL Fantasy Football Insights #EPL#Fanton Fanton EN provides updates for fantasy football fans with matches including Aston Villa against a lower-ranked team and Chelsea hosting Man United. Key players like Ollie Watkins and Enzo Fernández are highlighted for potential fantasy lineups. Participate in the EPL Double Tournament with an entry fee of $9 to secure top spots. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7231 · 15.05.2025 г., 18:16

Fanton EN: Secure Your Spot for the EPL Grand Tournament #EPL#Fanton Fanton EN is offering a promotional opportunity for players to secure tickets to the EPL Grand Tournament with a $2,000 guarantee. By making 7 entries by May 17th at 21:00 UTC, players can receive an additional free lineup and have the chance for more tickets by increasing their entries. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7131 · 09.05.2025 г., 07:58

⚡️Fanton EN: Last Call for EPL Grand Tournament Registration #Fanton#EPL Fanton EN announces the closing of registration for the English Premier League Grand Tournament, with $3,000 guaranteed. Top players in categories such as goalkeepers and defenders are highlighted, encouraging participation from fantasy players. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #6734 · 12.04.2025 г., 11:43

Fanton EN: New EPL Round Registration Closing Soon #EPL#Fanton Fanton EN invites participants to join the new EPL round with a $9 entry fee, featuring matches between Brighton vs Leicester, Nottm Forest vs Everton, and Southampton vs Aston Villa. Registration concludes in 2.5 hours. Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7649 · 29.11.2025 г., 13:20

Fanton EN: EPL Tournament Begins Soon! #EPL#tournament Fanton EN announces that the EPL tournament with a $300 prize pool is starting in 1.5 hours. Participants can enter for a 9 USDT fee and compete in the 4+1 format. Source: link @tonlines

TONlines – News

@tonlines · Post #6787 · 15.04.2025 г., 17:41

⚡️Fanton EN: Exciting Grand Tournament Returns! #Tournament#EPL Fanton EN announces the return of the EPL Grand Tournament with a $5,000 prize pool. The tournament will take place on April 19–20 and offers thrilling competition for participants with a $9 USDT entry fee. Source: link @tonlines

TONlines – News

@tonlines · Post #7687 · 02.12.2025 г., 17:35

⚡️Fanton EN: Exciting EPL Midweek Tournament! #EPL#prizes Fanton EN is hosting an exciting English Premier League tournament with a $200 prize pool. Don’t miss the matches from December 2-4, including Newcastle vs Tottenham and Fulham vs Man City. Join now with a $9 entry fee and compete for the prize! Source: link @tonlines

Hashtags

TONlines – News

@tonlines · Post #7153 · 10.05.2025 г., 08:11

⚡️Fanton EN: Grand EPL Tournament Kicks Off Soon! #Fanton#USDT#EPL The Fanton EN channel announces the upcoming Grand EPL Tournament offering a prize pool of $3,000. Participants can join by building their teams and competing to win USDT or $FTON with an entry fee of just $11. Source: link @tonlines

12
ПретходнаСтраница 1 од 2Следна