Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!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.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'newline': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'looked': 0.10; '"."': 0.16; 're,': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'skip:^ 20': 0.16; 'slash': 0.16; 'slashes': 0.16; 'string': 0.17; 'char': 0.17; 'variable': 0.20; 'needed.': 0.23; "i've": 0.23; 'seems': 0.23; 'header:User- Agent:1': 0.26; 'looks': 0.26; 'skip:[ 10': 0.26; '(see': 0.27; 'set.': 0.27; 'header:X-Complaints-To:1': 0.28; 'grouping': 0.29; 'class': 0.29; 'maybe': 0.29; 'returned': 0.30; 'code': 0.31; 'accessible': 0.33; 'to:addr:python-list': 0.33; 'another': 0.33; 'wrong': 0.34; 'received:org': 0.36; 'but': 0.36; 'should': 0.36; 'charset:us-ascii': 0.36; 'does': 0.37; 'two': 0.37; 'some': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'end': 0.40; 'think': 0.40; 'range': 0.60; 'more': 0.63; 'walk': 0.71; 'special': 0.73; 'case?': 0.84; 'received:sd.cox.net': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: rh Subject: regex walktrough Date: Sat, 8 Dec 2012 09:48:13 -0800 Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: ip184-187-163-27.sb.sd.cox.net User-Agent: dsodnetnin X-Mailer: EZnn0.37p X-Newsreader: EZnn0.37p X-Gmane-NNTP-Posting-Host: EZnn0.37p Original-Received: from slem by 1.1 with local X-No-Archive: yes Archive: no X-Archive: expiry=11 X-Archive: encrypt X-Operating-System: Barebones_6.1 X-Gmane-NNTP-Posting-Host: 192.168.1.1 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: 24 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1354988907 news.xs4all.nl 6907 [2001:888:2000:d::a6]:48106 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:34497 Look through some code I found this and wondered about what it does: ^(?P[0-9A-Za-z-_.//]+)$ Here's my walk through: 1) ^ match at start of string 2) ?P if a match is found it will be accessible in a variable salsipuedes 3) [0-9A-Za-z-_.//] this is the one that looks wrong to me, see below 4) + one or more from the preceeding char class 5) () the grouping we want returned (see #2) 6) $ end of the string to match against but before any newline more on #3 the z-_ part looks wrong and seems that the - should be at the start of the char set otherwise we get another range z-_ or does the a-z preceeding the z-_ negate the z-_ from becoming a range? The "." might be ok inside a char set. The two slashes look wrong but maybe it has some special meaning in some case? I think only one slash is needed. I've looked at pydoc re, but it's cursory.