⊗pyPmREMMP 67 of 128 menu

Pockets in Python's match method

When working with the match method, you can split the found substring into pockets.

Let's say we have a line:

txt = '12 34 56'

Let's find the first substring with numbers and split it into two pockets:

res = re.match('(\d+)(\d+)', txt) print(res[0]) # '12' print(res[1]) # '1' print(res[2]) # '2'

Given a string:

txt = 'code.mu 1234'

Find the domain located at the beginning of the line and put its name in the first pocket and the zone in the second.

Given a string containing a domain:

txt = 'sss domain.ru zzz'

Find this domain and put its name in the first pocket and the zone in the second.

Given a string containing a date:

txt = '31.12.2025'

Place the day in the first pocket, the month in the second, and the year in the third.

English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline