Letter class in re

Antoon Pardon antoon.pardon at rece.vub.ac.be
Tue Mar 10 04:35:28 EDT 2015


Op 09-03-15 om 17:11 schreef Steven D'Aprano:
> Antoon Pardon wrote:
>
>> I am using PLY for a parsing task which uses re for the lexical
>> analysis. 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.
>>
>> I am using python 3.4
>
> The re module in Python is pretty old and basic. Can you use Matthew
> Barnett's regex module, available on PyPI? I understand it has a richer set
> of flags for things such as Unicode letters and the like.

Not really. I could use regex to build a lexer but that would mean having to do
a lot of extra work, since I couldn't use the abstraction that is offered by PLY.lex.
PLY.yacc allows the use of a different lexer but PLY.lex doesn't allow the use
of a different regular expression engine.

-- 
Antoon Pardon




More information about the Python-list mailing list