Regex Doubts
Iranna Mathapati
iranna.gani28 at gmail.com
Fri Mar 30 02:16:38 EDT 2018
Hi Team,
how to achieve fallowing expected output?
str_output= """
MOD1 memory : 2 valid 1790 free
MOD2 memory : 128 valid 128 free
UDP Aware *MEMR* : 0 valid 0 free *MEMR
: 21 valid 491 free
<<<<<expecting *
Feature XYZ : 3 valid 13 free
Feature PQR : 0 valid 16 free
Feature MNO : 0 valid 2 free
"""
i am going to grep MEM values alone and i have tried fallowing Regex:
re.findall(r'MEMR\s+\:\s+([0-9]+)\s+valid \s+([0-9]+)\s+free ', str_output)
it produce fallowing output::
[('0', '0'), ('21', '491')]
Expected output and i am expecting fallowing output::
*[('21' ,'491')] <<<<< how to achieve this output?*
Thanks,
Iranna
More information about the Python-list
mailing list