[issue7132] Regexp: capturing groups in repetitions

Philippe Verdy report at bugs.python.org
Thu Oct 15 02:00:20 CEST 2009


Philippe Verdy <verdy_p at wanadoo.fr> added the comment:

> Even with your solution, in most of the cases you will need additional
steps to assemble the results (at least in the cases with some kind of
separator, where you have to join the first element with the 
followings).

Yes, but this step is trivial and fully predictable. Much more viable 
than the other solutions proposed which gives tricky and often complex 
and bogous code.

How many bugs have been found in code using split() for example to parse 
URLs ? There are countlesss in many softwares (and it is not terminated 
!)

And in fine, the only solution is to simply rewrite the parser 
completely, without regexps at all, or to reduce the generality of the 
problems that the program was supposed to solve (i.e. asserting in the 
code some implementation limits, to reject some forms that were 
previously considered valid). Think about it, the capturing groups are 
the perfect solution for solving the problem cleanly, provided that they 
work as intended and return all their occurences.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7132>
_______________________________________


More information about the Python-bugs-list mailing list