Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'from:addr:yahoo.co.uk': 0.04; 'say,': 0.05; 'compiler': 0.07; 'expressions': 0.07; 'subject:Questions': 0.07; 'suppose': 0.07; 'string': 0.09; 'ascii': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'jan': 0.12; 'suggest': 0.14; 'wrote': 0.14; 'language.': 0.14; "wouldn't": 0.14; '4-5': 0.16; 'cocoa,': 0.16; 'hex': 0.16; 'inclined': 0.16; 'listed,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'skip:[ 60': 0.16; 'variations': 0.16; 'language': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; 'not,': 0.20; '>>>': 0.22; 'example': 0.22; 'header:User-Agent:1': 0.23; 'certainly': 0.24; 'mon,': 0.24; "i've": 0.25; 'equivalent': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'character': 0.29; 'characters': 0.30; 'errors': 0.30; "i'm": 0.30; 'are.': 0.31; 'fans': 0.31; 'this.': 0.32; 'figure': 0.32; "i'd": 0.34; "can't": 0.35; 'agree': 0.35; 'but': 0.35; 'should': 0.36; 'error.': 0.37; 'sometimes': 0.38; 'somebody': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'issue': 0.38; 'extremely': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'range': 0.61; "you're": 0.61; 'our': 0.64; 'more': 0.64; 'smith': 0.68; 'article': 0.77; 'a-z,': 0.84; 'beer,': 0.84; 'tricky': 0.84; 'warnings.': 0.84; 'imagine': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: re Questions Date: Sun, 26 Jan 2014 17:39:20 +0000 References: <3f568767-e13a-4c7d-a4fb-85caca2adf6e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-146-11-250.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 In-Reply-To: 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: 38 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1390757975 news.xs4all.nl 2877 [2001:888:2000:d::a6]:50174 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:64786 On 26/01/2014 17:25, Chris Angelico wrote: > On Mon, Jan 27, 2014 at 4:15 AM, Roy Smith wrote: >> In article , >> Chris Angelico wrote: >> >>> The set [A-z] is equivalent to >>> [ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz] >> >> I'm inclined to suggest the regex compiler should issue a warning for >> this. >> >> I've never seen a character range other than A-Z, a-z, or 0-9. Well, I >> suppose A-F or a-f if you're trying to match hex digits (and some >> variations on that for octal). But, I can't imagine any example where >> somebody wrote A-z and it wasn't an error. > > I've used a variety of character ranges, certainly more than the 4-5 > you listed, but I agree that A-z is extremely likely to be an error. > However, I've sometimes used a regex (bytes mode) to find, say, all > the ASCII printable characters - [ -~] - and I wouldn't want that > precluded. It's a bit tricky trying to figure out which are likely to > be errors and which are not, so I'd be inclined to keep things as they > are. No warnings. > > ChrisA > I suggest a single warning is always given "Regular expressions can be fickle. Have you considered using string methods?". My apologies to regex fans if they're currently choking over their tea, coffee, cocoa, beer, scotch, saki, ouzo or whatever :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence