re.compile
Peter Otten
__peter__ at web.de
Tue Nov 25 03:46:53 EST 2003
Jenny Edmondson wrote:
> What does re.compile("(.+)<(.+)>(.+)") do?
>>> r = re.compile("(.+)<(.+)>(.+)")
>>> r.match("something to begin with<something inside>something that
follows").groups()
('something to begin with', 'something inside', 'something that follows')
>>>
In detail:
(.+) matches at least one ("+") character ("."=any character) and remembers
it (the enclosing "(...)")
< matches a "<"
> matches a ">"
compile() prepares the regular expression for faster matching.
For more information see
http://www.python.org/doc/current/lib/module-re.html
Peter
More information about the Python-list
mailing list