Positions of regexp groups

John Machin sjmachin at lexicon.net
Fri Apr 8 09:48:27 EDT 2005


On Fri, 8 Apr 2005 13:18:27 +0000 (UTC), mlh at selje.idi.ntnu.no (Magnus
Lie Hetland) wrote:

>Just a quick question: Does anyone have a simple way of finding the
>positions (start, end) of the groups in a regexp match? AFAICS, the re
>API can only return the contents...?

These documented methods of the match object aren't simple enough???
"""
start( [group]) 
end( [group]) 

Return the indices of the start and end of the substring matched by
group
"""


and there's span() which returns a tuple (start, end) ... what simpler
could you ask for, Mr Occam?





More information about the Python-list mailing list