Re: Positions of regexp groups

2005-04-10 Thread Magnus Lie Hetland
In article <[EMAIL PROTECTED]>, Tim
Peters wrote:
>[Magnus Lie Hetland]
>> 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...?
>
>Read the docs for match objects, esp. the start(), end(), and span()
>methods.

Right. I was just now editing the regex-stuff in my book for the
second edition, and found that I had, in fact, written about just this
behaviour. 

Oh, well. I guess it's a feature I don't use much :}

Thanks, anyway.

-- 
Magnus Lie HetlandFall seven times, stand up eight
http://hetland.org  [Japanese proverb]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Positions of regexp groups

2005-04-08 Thread John Machin
On Fri, 8 Apr 2005 13:18:27 + (UTC), [EMAIL PROTECTED] (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?


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Positions of regexp groups

2005-04-08 Thread Tim Peters
[Magnus Lie Hetland]
> 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...?

Read the docs for match objects, esp. the start(), end(), and span() methods.
-- 
http://mail.python.org/mailman/listinfo/python-list


Positions of regexp groups

2005-04-08 Thread Magnus Lie Hetland
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...?

-- 
Magnus Lie HetlandFall seven times, stand up eight
http://hetland.org  [Japanese proverb]
-- 
http://mail.python.org/mailman/listinfo/python-list