Eliminating the "invalid character range"?

Mistake:

Exception Value:     bad character range
Exception Location:  /usr/lib/python2.6/re.py in _compile, line 245
Python Executable:   /usr/bin/python

      

I have no idea what this means. Can anyone guess or point me in the right direction?

Everything worked great before. I only changed a few trivial bits of code!: S

if "-" in stop:
    dt1 = datetime.strptime(stop, "%Y-%m-%dT%H:%M:%S")
    stopInS = time.mktime(dt1.timetuple())
    stopInMS = int(startInS) * 1000
else:
    splitter = re.compile(r'[\D]')
    preStop = splitter.split(stop)
    stopInMS = ''.join(preStop)

      

I was just playing around with double quotes before the "in" ... then it all crashed with this error.

EDIT:

Another regular expression is present:

    splitter1 = re.compile('[:]')
    arrayOfIDs = splitter1.split(identifier)
    idLens = len(arrayOfIDs)

      

+2


source to share


1 answer


The exception you are getting is that the python re.py module cannot compile the regex somewhere because you have a bad character range.

Ranges of characters are such as [a-z0-9]

(accepts a lowercase letter or number).

For example:



import re
re.compile('[a-0]')

      

raises the exception bad character range

you are getting. Look for somewhere you're creating a character range that doesn't make sense (it doesn't [:]

, which compiles perfectly).

+7


source







All Articles