possible bug in re expression?
Robin Becker
robin at reportlab.com
Mon Apr 28 09:06:08 EDT 2014
On 28/04/2014 12:49, Steven D'Aprano wrote:
......
>
> Well, I don't know about "almost any", but at least some broken regexes
> will explicitly fail:
>
>
>
> py> import re
........
> sre_constants.error: nothing to repeat
>
> (For brevity I have abbreviated the traceback.)
>
so there is intent to catch some specification errors.
I've abandoned this translation anyhow as all that was intended was to split the
string into non-overlapping strings of size at most k. I find this works faster
than the regexp even if the regexp is pre-compiled.
[p[i:i+k] for i in xrange(0,len(p),k)]
--
Robin Becker
More information about the Python-list
mailing list