nested grouping with regular expressions

Fredrik Lundh fredrik at pythonware.com
Mon May 24 03:01:51 EDT 2004


"ds2000" wrote:

> Unfortunately,  re.match("<(..)*>", string).groups()  will return only
> the groups correspond to the last occurence of (regex)
>
> Is it possible to get a more tree-like group match (i.e. or at least a
> list which will contain the groups of each regex occurence).

use re.findall

(you may have to use multiple REs; a re.search to find the entire
group, a re.findall/finditer to split it up).

</F>







More information about the Python-list mailing list