Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #62425

RE: Regular Expression : Bad Character Range

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <ycui@outlook.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.042
X-Spam-Evidence '*H*': 0.92; '*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; 'thu,': 0.19; 'putting': 0.22; 'to:name:python-list@python.org': 0.22; 'error': 0.23; 'issue,': 0.24; 'subject: : ': 0.26; 'header:In-Reply-To:1': 0.27; 'character': 0.29; 'raise': 0.29; 'dec': 0.30; "i'm": 0.30; 'url:mailman': 0.30; 'regular': 0.32; 'url:python': 0.33; '(most': 0.33; 'date:': 0.34; 'skip:_ 10': 0.34; 'could': 0.34; 'except': 0.35; 'returning': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; 'url:org': 0.36; 'should': 0.36; 'email addr:python.org': 0.37; '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; 'subject:': 0.39; 'bad': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'expression': 0.60; 'range': 0.61; 'email name:python-list': 0.65; 'frank': 0.68; 'hints': 0.68; 'invalid': 0.68; '-0300': 0.84; '241': 0.84; '2013': 0.98
X-TMN [P6BwqPHK01zH4wzQuXy0Uty8ymsS5uDJ]
X-Originating-Email [ycui@outlook.com]
Content-Type multipart/alternative; boundary="_9ec159a3-67b7-480d-a367-5302fc272aac_"
From Frank Cui <ycui@outlook.com>
To "python-list@python.org" <python-list@python.org>
Subject RE: Regular Expression : Bad Character Range
Date Thu, 19 Dec 2013 23:53:04 -0300
Importance Normal
In-Reply-To <BAY176-W21EE1C4E4FB47763A147C7DAC40@phx.gbl>
References <BAY176-W21EE1C4E4FB47763A147C7DAC40@phx.gbl>
MIME-Version 1.0
X-OriginalArrivalTime 20 Dec 2013 03:23:06.0707 (UTC) FILETIME=[CCD5AA30: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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.4425.1387509854.18130.python-list@python.org> (permalink)
Lines 122
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1387509854 news.xs4all.nl 2951 [2001:888:2000:d::a6]:53146
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:62425

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

should have escaped hyphen as it could be used for ranging. 

sorry for the bother...

From: ycui@outlook.com
To: python-list@python.org
Subject: Regular Expression : Bad Character Range
Date: Thu, 19 Dec 2013 23:50:52 -0300




Hey guys,

I'm trying to compile a regular Expression while encountering the following issue, 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

 		 	   		  

-- 
https://mail.python.org/mailman/listinfo/python-list 		 	   		  

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

RE: Regular Expression : Bad Character Range Frank Cui <ycui@outlook.com> - 2013-12-19 23:53 -0300

csiph-web