regular expression
Jeff Shipman
shippy at cs.nmt.edu
Thu Feb 24 11:40:28 EST 2000
I never gave you a very good example for my advice!
Instead of:
result = pattern.search(data)
which will match the whole line (not just the stuff in the parens),
you could use
result = pattern.sub('\g<1>', data)
and then result will equal everything that's in
(.*?) assuming your regular expression has been
written properly. (sub() is a substitution function).
Hope that helps!
--
+-----------------------------------------------------+
| Jeff "Shippy" Shipman E-Mail: shippy at cs.nmt.edu |
| Computer Science Major ICQ: 1786493 |
| New Mexico Institute of Mining and Technology |
| Homepage: http://www.nmt.edu/~shippy |
+-----------------------------------------------------+
More information about the Python-list
mailing list