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


Groups > comp.lang.python > #87197

Re: Letter class in re

Path csiph.com!usenet.pasdenom.info!news.redatomik.org!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <fomcl@yahoo.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.195
X-Spam-Level *
X-Spam-Evidence '*H*': 0.61; '*S*': 0.00; '[1]:': 0.09; '[2]:': 0.09; 'underscore': 0.09; 'subject:class': 0.16; 'to:addr:python.list': 0.16; 'to:addr:tim.thechases.com': 0.16; 'to:name:tim chase': 0.16; 'wrote:': 0.18; 'slightly': 0.19; 'unicode': 0.24; 'mon,': 0.24; 'header:In-Reply-To:1': 0.27; 'to:2**1': 0.27; 'skip:- 40': 0.29; 'am,': 0.29; 'tim': 0.29; 'assert': 0.31; 'chase': 0.31; 'anyone': 0.31; 'class': 0.32; 'regular': 0.32; 'monday,': 0.33; 'date:': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'sequence': 0.36; 'email addr:python.org': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'subject:': 0.39; 'to:addr:python.org': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'expression': 0.60; 'received:98.137': 0.60; 'march': 0.61; 're:': 0.63; 'more': 0.64; 'different': 0.65; 'email name:python-list': 0.65; 'received:gq1.yahoo.com': 0.68; 'received:mail.gq1.yahoo.com': 0.68; 'received:98.136': 0.69; '"one': 0.84; 'pardon': 0.84; 'received:bullet.mail.gq1.yahoo.com': 0.84; 'ugly,': 0.84; 'subject:Letter': 0.93
X-Yahoo-Newman-Property ymail-3
X-Yahoo-Newman-Id 766572.91523.bm@omp1029.mail.gq1.yahoo.com
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1425908003; bh=OxpvORjqmm4Y+DurncGBK/9ufRpuJq/1I0mEZyCgo30=; h=Message-ID:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=rzntqD888S5eMJFnXuSGTR/iCL00cUrSfh0pWVBA/8p5+WrffV+NBT3wiUf68IKtKL5DZ17BR51Q/K6LodB7Pb+Tek2NEJ8bTUnS6KESszynvFxNsdnXhT7JxWZWUWbk9H2urS/Nq0TC4mrMJ8aCd1w6RAixKRFnjn+TMB5E8HQ=
X-YMail-OSG EBYi2rgVM1mo7gUeLf4eLoawJFCbOu1HIBGtfe_Ee26LrOy CX1zaCAmfcIw9oirt4LR9vtDFca3D.awl_uYPjnuDbUcR26bzVEFaFxjDWw9 zpOsy3.GONDJdgUaT1tHaKQRe8lE3j7yGOZvO1JwXTVbOV4MQmACbBpTmYtx Euab28ysey8RpLOJLkfospkn27xOXYFBcPx8ix_EgQUWqfs_Tf0MhfH4C8p6 mmIkciaxRa6f43_SDnnAvb9CRTWCRp78JoPcfm3Lk.dnCns2Pi4OTvX86HBv OpF9ajM0q9siPPlKsppVWc2tyXBt.nRapNNXVmhqvjA7qnMaCKxaqAmjPFJD xp0Wwf3KFKmdEZYCMFPhY.2BwMhKs4Ob.8fZYqjl1ad2y6KzRgyP7qZiLDpo m1j.bxadzWzyIBUNLmTJG.GKqaeNBsEQkYTDOfyNti4RXXYsGwhytFZNSiZM op0hPKmi5Uq1nMC85FkkYsi7r55keAclA_4aq9KkI_7f.bdHuy6idf_kDzR1 FkUgmo.14n9elOWfIjab9ttI4L19aaa6DdiCsNVR5LzkSeA5RavAFa_ouWUX d
X-Rocket-MIMEInfo 002.001, LS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0NCk9uIE1vbiwgMy85LzE1LCBUaW0gQ2hhc2UgPHB5dGhvbi5saXN0QHRpbS50aGVjaGFzZXMuY29tPiB3cm90ZToNCg0KIFN1YmplY3Q6IFJlOiBMZXR0ZXIgY2xhc3MgaW4gcmUNCiBUbzogcHl0aG9uLWxpc3RAcHl0aG9uLm9yZw0KIERhdGU6IE1vbmRheSwgTWFyY2ggOSwgMjAxNSwgMTI6MTcgUE0NCiANCiBPbiAyMDE1LTAzLTA5IDExOjM3LA0KIFdvbGZnYW5nIE1haWVyIHdyb3RlOg0KID4gT24gMDMvMDkvMjAxNQ0KIDExOjIBMAEBAQE-
X-Mailer YahooMailClassic/406 YahooMailWebService/0.8.203.740
Date Mon, 9 Mar 2015 06:33:23 -0700
From Albert-Jan Roskam <fomcl@yahoo.com>
Subject Re: Letter class in re
To python-list@python.org, Tim Chase <python.list@tim.thechases.com>
In-Reply-To <20150309061736.07e0d944@bigbox.christie.dr>
MIME-Version 1.0
Content-Type text/plain; charset=iso-8859-1
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.19
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.207.1425908185.21433.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1425908185 news.xs4all.nl 2887 [2001:888:2000:d::a6]:43905
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:87197

Show key headers only | View raw


--------------------------------------------
On Mon, 3/9/15, Tim Chase <python.list@tim.thechases.com> wrote:

 Subject: Re: Letter class in re
 To: python-list@python.org
 Date: Monday, March 9, 2015, 12:17 PM
 
 On 2015-03-09 11:37,
 Wolfgang Maier wrote:
 > On 03/09/2015
 11:23 AM, Antoon Pardon wrote:
 >> Does
 anyone know what regular expression to use for a sequence
 of
 >> letters? There is a class for
 alphanumerics but I can't find one
 >> for just letters, which I find odd.
 > 
 > how about [a-zA-Z]
 ?
 
 That breaks if you have
 Unicode letters.  While ugly, since "\w" is
 composed of "letters, numbers, and
 underscores", you can assert that
 the
 "\w" you find is not a number or underscore by
 using
 
   (?:(?!_|\d)\w)
 

I was going to make the same remark, but with a slightly different solution: 
In [1]: repr(re.search("[a-zA-Z]", "é"))
Out[1]: 'None'
 
In [2]: repr(re.search(u"[^\d\W_]+", u"é", re.I | re.U))
Out[2]: '<_sre.SRE_Match object at 0x027CDB10>'

"[^\d\W_]+" means something like "one or more (+) of 'not (a digit, a non-word, an underscore)'.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Letter class in re Albert-Jan Roskam <fomcl@yahoo.com> - 2015-03-09 06:33 -0700

csiph-web