Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #87202
| Date | 2015-03-09 07:50 -0500 |
|---|---|
| From | Tim Chase <python.list@tim.thechases.com> |
| Subject | Re: Letter class in re |
| References | <54FD74BA.8010803@rece.vub.ac.be> <mdjt75$jpu$1@ger.gmane.org> <20150309061736.07e0d944@bigbox.christie.dr> <54FD918B.1030702@rece.vub.ac.be> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.211.1425909962.21433.python-list@python.org> (permalink) |
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
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Letter class in re Tim Chase <python.list@tim.thechases.com> - 2015-03-09 07:50 -0500
csiph-web