regular expression question
Ben Finney
bignose-hates-spam at and-benfinney-does-too.id.au
Tue Jan 20 19:30:50 EST 2004
On Wed, 21 Jan 2004 00:38:12 -0000, Steve Lamb wrote:
> import re
> line = 'match this'
> foo = re.search(r'.*(this)', line)
> foo.groups()[0]
>>> import re
>>> line = 'match this'
>>> foo = re.search( r'.*(this)', line )
>>> foo.groups()
('this',)
>>> foo.group(0)
'match this'
>>> foo.group(1)
'this'
Read more on the methods available from a MatchObject:
<http://www.python.org/doc/lib/match-objects.html>
--
\ "The man who is denied the opportunity of taking decisions of |
`\ importance begins to regard as important the decisions he is |
_o__) allowed to take." -- C. Northcote Parkinson |
Ben Finney <http://bignose.squidly.org/>
More information about the Python-list
mailing list