Letter class in re

Antoon Pardon antoon.pardon at rece.vub.ac.be
Mon Mar 9 11:39:54 EDT 2015


Op 09-03-15 om 14:33 schreef Albert-Jan Roskam:
> 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)'.
>
Nice, I am seriously considering this, if only because I have less trouble
understanding this. I'll run some tests to see what gives.

-- 
Antoon Pardon




More information about the Python-list mailing list