Regular Expression : Bad Character Range

F

Frank Cui

Hey guys,

I'm trying to compile a regular Expression while encountering the followingissue, any hints ?

is hyphen "-" or underscore "_" considered any meta character which is not allowed when putting into the range ?

Thanks
Frank

In [2]: re.compile("[\w-_]+>")
---------------------------------------------------------------------------
error Traceback (most recent call last)
/home/frank/<ipython-input-2-ee4b44c4d17a> in <module>()
----> 1 re.compile("[\w-_]+>")

/usr/lib/python2.7/re.pyc in compile(pattern, flags)
188 def compile(pattern, flags=0):
189 "Compile a regular expression pattern, returning a pattern object."
--> 190 return _compile(pattern, flags)
191
192 def purge():

/usr/lib/python2.7/re.pyc in _compile(*key)
240 p = sre_compile.compile(pattern, flags)
241 except error, v:
--> 242 raise error, v # invalid expression
243 if len(_cache) >= _MAXCACHE:
244 _cache.clear()

error: bad character range
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top