Regex to extract multiple fields in the same line

Ganesh Pal ganesh1pal at gmail.com
Fri Jun 15 05:04:45 EDT 2018


>
>>>> {'struct': 'data_block', 'log_file': '/var/1000111/test18.log', 'loc':
> '0', 'size': '8'}
>
>
MARB, as usual the solution you you look nice, Thanks for the excellent
solutions

>>> regex = re.compile (r"--(struct|loc|size|mirror|l
og_file)\s*=\s*([^\s]+)")
>>> regex.findall (line)
[('struct', 'data_block'), ('log_file', '/var/1000111/test18.log'), ('loc',
'0'), ('mirror', '10')]

Frederic  , this look  great, thanks for your response



More information about the Python-list mailing list