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


Groups > comp.lang.python > #87202 > unrolled thread

Re: Letter class in re

Started byTim Chase <python.list@tim.thechases.com>
First post2015-03-09 07:50 -0500
Last post2015-03-09 07:50 -0500
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Letter class in re Tim Chase <python.list@tim.thechases.com> - 2015-03-09 07:50 -0500

#87202 — Re: Letter class in re

FromTim Chase <python.list@tim.thechases.com>
Date2015-03-09 07:50 -0500
SubjectRe: Letter class in re
Message-ID<mailman.211.1425909962.21433.python-list@python.org>
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


[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web