⊗pyPmREFNP 63 of 128 menu

Named pockets in finditer method in Python

When using the finditer method, named pockets can be used:

txt = 'aaaa 123 bbbb 456' res = re.finditer('(?P<test1>\d)(?P<test2>\d)', txt) for el in res: print(el[0], el['test1'], el['test2'])

Result of code execution:

'12 1 2' '45 4 5'

Given a string:

txt = '456 aaa 123 b2bb 987'

Find all substrings containing only digits and distribute them into two named pockets. Print them using a loop.

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