Path: csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed3a.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.014 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'python3': 0.07; 'underscore': 0.09; 'cc:addr:python-list': 0.11; '-tkc': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'identifier,': 0.16; 'identifier.': 0.16; 'received:10.21': 0.16; 'received:174.136': 0.16; 'subject:class': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'header:In- Reply-To:1': 0.27; 'character': 0.29; 'tim': 0.29; 'regular': 0.32; "can't": 0.35; 'acceptable': 0.36; 'charset:us-ascii': 0.36; 'should': 0.36; 'received:10': 0.37; 'even': 0.60; 'expression': 0.60; 'further': 0.61; 'first': 0.61; 'pardon': 0.84; 'subject:Letter': 0.93 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1425905332766:629714119 X-MC-Ingress-Time: 1425905332766 Date: Mon, 9 Mar 2015 07:50:17 -0500 From: Tim Chase To: Antoon Pardon Cc: python-list@python.org Subject: Re: Letter class in re In-Reply-To: <54FD918B.1030702@rece.vub.ac.be> References: <54FD74BA.8010803@rece.vub.ac.be> <20150309061736.07e0d944@bigbox.christie.dr> <54FD918B.1030702@rece.vub.ac.be> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AuthUser: tim@thechases.com X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.19 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: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1425909962 news.xs4all.nl 2859 [2001:888:2000:d::a6]:37308 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:87202 On 2015-03-09 13:26, Antoon Pardon wrote: > Op 09-03-15 om 12:17 schreef Tim Chase: >> (?:(?!_|\d)\w) > > So if I understand correctly the following should be a regular > expression for a python3 identifier. > > (?:(?!_|\d)\w)\w+ If you don't have to treat it as an atom, you can simplify that to just (?!_|\d)\w+ which just means that the first character can't be an underscore or digit. Though for a Py3 identifier, the underscore is acceptable as a first character ("__init__"), so you can simplify it even further to just (?!\d)\w+ -tkc