Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin2!goblin.stu.neva.ru!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.037 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'error:': 0.07; '[2]:': 0.09; 'underscore': 0.09; 'def': 0.12; '"-"': 0.16; '"_"': 0.16; '240': 0.16; 'guys,': 0.16; 'last)': 0.16; 'subject:Regular': 0.16; 'hey': 0.18; 'trying': 0.19; 'putting': 0.22; 'to:name :python-list@python.org': 0.22; 'error': 0.23; 'issue,': 0.24; 'subject: : ': 0.26; 'character': 0.29; 'raise': 0.29; "i'm": 0.30; 'regular': 0.32; '(most': 0.33; 'skip:_ 10': 0.34; 'except': 0.35; 'returning': 0.36; 'thanks': 0.36; 'skip:& 10': 0.38; 'to:addr:python-list': 0.38; 'received:65.54': 0.38; 'received:65.54.190': 0.38; 'received:bay0.hotmail.com': 0.38; 'recent': 0.39; 'bad': 0.39; 'to:addr:python.org': 0.39; 'expression': 0.60; 'range': 0.61; 'frank': 0.68; 'hints': 0.68; 'invalid': 0.68; '241': 0.84; 'received:65.54.190.29': 0.91; 'received:bay0-omc1-s18.bay0.hotmail.com': 0.91 X-TMN: [qwXpj4Q3lC6WLgwLrfWeI8CuvdfNXdaB] X-Originating-Email: [ycui@outlook.com] Content-Type: multipart/alternative; boundary="_35ef45d1-4402-4cd6-9a12-107d7d873bcc_" From: Frank Cui To: "python-list@python.org" Subject: Regular Expression : Bad Character Range Date: Thu, 19 Dec 2013 23:50:52 -0300 Importance: Normal MIME-Version: 1.0 X-OriginalArrivalTime: 20 Dec 2013 03:20:53.0441 (UTC) FILETIME=[7D66E310:01CEFD32] X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 88 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1387509722 news.xs4all.nl 2880 [2001:888:2000:d::a6]:50580 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:62424 --_35ef45d1-4402-4cd6-9a12-107d7d873bcc_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hey guys=2C I'm trying to compile a regular Expression while encountering the following= issue=2C 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/ in () ----> 1 re.compile("[\w-_]+>") /usr/lib/python2.7/re.pyc in compile(pattern=2C flags) 188 def compile(pattern=2C flags=3D0): 189 "Compile a regular expression pattern=2C returning a pattern ob= ject." --> 190 return _compile(pattern=2C flags) 191=20 192 def purge(): /usr/lib/python2.7/re.pyc in _compile(*key) 240 p =3D sre_compile.compile(pattern=2C flags) 241 except error=2C v: --> 242 raise error=2C v # invalid expression 243 if len(_cache) >=3D _MAXCACHE: 244 _cache.clear() error: bad character range = --_35ef45d1-4402-4cd6-9a12-107d7d873bcc_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hey guys=2C

I'm trying to= compile a regular Expression while encountering the following issue=2C any= hints ?

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

Thanks
Fran= k

In [2]: re.compile("[\w-_]+>=3B")
---------------------------= ------------------------------------------------
error =3B =3B&n= bsp=3B =3B =3B =3B =3B =3B =3B =3B =3B = =3B =3B =3B =3B =3B =3B =3B =3B =3B =3B=  =3B =3B =3B =3B =3B =3B =3B =3B =3B&nb= sp=3B =3B =3B =3B =3B =3B Traceback (most recent call l= ast)
/home/frank/<=3Bipython-input-2-ee4b44c4d17a>=3B in <=3Bmodul= e>=3B()
---->=3B 1 re.compile("[\w-_]+>=3B")

/usr/lib/pytho= n2.7/re.pyc in compile(pattern=2C flags)
 =3B =3B =3B 188 de= f compile(pattern=2C flags=3D0):
 =3B =3B =3B 189 =3B&nb= sp=3B =3B =3B "Compile a regular expression pattern=2C returning a = pattern object."
-->=3B 190 =3B =3B =3B =3B return _co= mpile(pattern=2C flags)
 =3B =3B =3B 191
 =3B = =3B =3B 192 def purge():

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

error: bad character range
<= br>
= --_35ef45d1-4402-4cd6-9a12-107d7d873bcc_--