split problem

Fredrik Lundh fredrik at effbot.org
Sun Nov 12 04:51:55 EST 2000


"yasho" wrote:
> The splitting is made in a loop so I am splitting the string into
> several parts. For example I have a string which in this particular case
> I must split into five parts but when I split it into 3 parts I get this
> error :
> File "convert.py", line 16 in?
> c=re.compile(svalue.group()).split(s,1)
> File ".........../re.py", line 79, in compile
> code=pcre_compile(pattern, flags, groupindex)
> pcre.error:('nothing to repeat',0)
> Does anybody knows what is happening with my script?

the error message ("nothing to repeat") means that your
regular expression is flawed.

printing svalue.group() just before the re.compile call
should help you figure out what's wrong.

:::

also note that you can replace re.compile(p).split(s, ...)
with re.split(p, s, ...)

</F>





More information about the Python-list mailing list