tags:

views:

108

answers:

1

Error:

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

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

It was all working fine before.. I've 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 merely playing around with the double quotes before the 'in'... then the whole thing collapsed with this error.

EDIT:

Another regex present:

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

The exception you're getting is because Python's re.py module can't compile a regular expression somewhere, because you've got a bad character range.

Character ranges are things like [a-z0-9] (accepts a lower-case letter or number).

For example:

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

raises the bad character range exception you're getting. Look for somewhere you're creating a character range that doesn't make sense (it's not [:], that compiles fine).

Dominic Rodger
I wish this worked :( Still getting the same error.
day_trader
Actually, I just tested compiling `r'[\D]'` and it compiles. Any other regexs around?
Dominic Rodger
And does the error go away if you remove that line and set `stopInMS` to some benign value?
Dominic Rodger
Indeed I have, just updated the original post!
day_trader
Thanks a lot! This pretty much fixed the problem (and my own stupidity!). Another quick question for you... is there a regular expression that accepts everything(to go in the urls.py for another one of my project)?
day_trader