⊗pyPmREMFP 60 of 128 menu

Pockets in Python's findall method

In the findall method, you can specify pockets to search for matches.

Let's say we have a line:

txt = '12 43 56 ab'

Let's find all the pairs of numbers and put them into pockets:

res = re.findall('(\d)(\d)', txt) print(res)

Result of code execution:

[('1', '2'), ('4', '3'), ('5', '6')]

The following line is given:

txt = '12:37 15:48 17:59';

Find all the substrings with time in it and for each found one, distribute the hours and minutes among the pockets.

Given a string:

txt = 'site.ru sss site.com zzz site.net';

Get domain names from this line by putting the domain name and its zone into different pockets.

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