Regular expression gone mad

plahey at alumni.caltech.edu plahey at alumni.caltech.edu
Mon Feb 20 11:49:26 EST 2006


This may not be enough for what you really want to do, but, given what
you have shown above, regex is the wrong tool for the job.

Use the string method startswith:

for line in ProcMem.split('\n'):
    if line.startswith( 'Mem' ):
        # do stuff




More information about the Python-list mailing list