regular expression question

Steve Lamb grey at despair.dmiyu.org
Tue Jan 20 19:38:12 EST 2004


    Ok, this just seems convluted.

import re
line = 'match this'
foo = re.search(r'.*(this)', line)
foo.groups()[0]

    To me there seems there should be a way to return a group without having
to get the tuple and then slice it out from there.  However foo.group(0) will
return the entire string (only one argument given) and groups doesn't seem to
do anything significant with any entry I give it.  Am I missing something
obvious or is this the final solution?

-- 
         Steve C. Lamb         | I'm your priest, I'm your shrink, I'm your
       PGP Key: 8B6E99C5       | main connection to the switchboard of souls.
-------------------------------+---------------------------------------------



More information about the Python-list mailing list