[Python-de] 1,2,3,5,7,8,9 -> "1-3,5,7-9"

Jan Voges jan.voges at gmx.de
Fre Jun 18 14:15:36 CEST 2004


Hallo nochmal!

On 18 Jun 2004 at 13:50, kgm wrote:
 
> Traceback (most recent call last):
>    File "C:\Test\liste-laufzeit.py", line 22, in ?
>      r = re.sub(r"-(\d+-)+","-",r)
>    File "C:\Programme\Python\lib\sre.py", line 143, in sub
>      return _compile(pattern, 0).sub(repl, string, count)
> RuntimeError: maximum recursion limit exceeded

Passiert nicht mehr (so schnell) mit:
r = re.sub(r"-\d+(?=-)","",r)

Jan