On Tue, 3/10/15, Antoon Pardon wrote:
Subject: Re: Letter class in re
To: python-list@python.org
Date: Tuesday, March 10, 2015, 9:35 AM
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
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 le
Op 09-03-15 om 16:17 schreef Tim Chase:
> On 2015-03-09 15:29, Antoon Pardon wrote:
>> Op 09-03-15 om 13:50 schreef Tim Chase:
(?:(?!_|\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 chara
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
On 2015-03-09 15:29, Antoon Pardon wrote:
> Op 09-03-15 om 13:50 schreef Tim Chase:
> >> (?:(?!_|\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.
>
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>
Op 09-03-15 om 15:44 schreef Chris Angelico:
> On Tue, Mar 10, 2015 at 1:41 AM, Antoon Pardon
> wrote:
>> Op 09-03-15 om 14:35 schreef Chris Angelico:
>>> On Mon, Mar 9, 2015 at 11:26 PM, Antoon Pardon
>>> wrote:
It seems odd that one should need such an ugly expression for something
t
Op 09-03-15 om 15:39 schreef Chris Angelico:
> On Tue, Mar 10, 2015 at 1:34 AM, Antoon Pardon
> wrote:
>>> There is str.isidentifier, which returns True if something is a valid
>>> identifier name:
>>>
>> '℮'.isidentifier()
>>> True
>> Which is not very usefull in a context of lexical analysis
On Tue, Mar 10, 2015 at 1:41 AM, Antoon Pardon
wrote:
> Op 09-03-15 om 14:35 schreef Chris Angelico:
>> On Mon, Mar 9, 2015 at 11:26 PM, Antoon Pardon
>> wrote:
>>> It seems odd that one should need such an ugly expression for something
>>> that is
>>> used rather frequently for parsing computer
Op 09-03-15 om 14:35 schreef Chris Angelico:
> On Mon, Mar 9, 2015 at 11:26 PM, Antoon Pardon
> wrote:
>> It seems odd that one should need such an ugly expression for something that
>> is
>> used rather frequently for parsing computer languages and the like.
> Possibly because computer language
On Tue, Mar 10, 2015 at 1:34 AM, Antoon Pardon
wrote:
>> There is str.isidentifier, which returns True if something is a valid
>> identifier name:
>>
>> >>> '℮'.isidentifier()
>> True
>
> Which is not very usefull in a context of lexical analysis. I don't need to
> know
> if a particular string i
Op 09-03-15 om 14:32 schreef Wolfgang Maier:
...
>
>> It seems odd that one should need such an ugly expression for
>> something that is
>> used rather frequently for parsing computer languages and the like.
>>
>
> There is str.isidentifier, which returns True if something is a valid
> identifier
Op 09-03-15 om 13:50 schreef Tim Chase:
> 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
On 03/09/2015 03:04 PM, Wolfgang Maier wrote:
On 03/09/2015 02:33 PM, Albert-Jan Roskam wrote:
On Mon, 3/9/15, Tim Chase wrote:
"[^\d\W_]+" means something like "one or more (+) of 'not (a digit, a
non-word, an underscore)'.
interesting (using Py
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 tha
On 03/09/2015 02:33 PM, Albert-Jan Roskam wrote:
On Mon, 3/9/15, Tim Chase wrote:
"[^\d\W_]+" means something like "one or more (+) of 'not (a digit, a non-word,
an underscore)'.
interesting (using Python3.4 and
U+2188 ROMAN NUMERAL ONE HUNDRED
On 09.03.15 14:26, Antoon Pardon wrote:
So if I understand correctly the following should be a regular expression for
a python3 identifier.
(?:(?!_|\d)\w)\w+
It seems odd that one should need such an ugly expression for something that is
used rather frequently for parsing computer languages
On Mon, 3/9/15, Tim Chase 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
an
On Mon, Mar 9, 2015 at 11:26 PM, Antoon Pardon
wrote:
> It seems odd that one should need such an ugly expression for something that
> is
> used rather frequently for parsing computer languages and the like.
Possibly because computer language parsers don't use regular expressions. :)
ChrisA
--
On 03/09/2015 01:26 PM, Antoon Pardon wrote:
Op 09-03-15 om 12:17 schreef Tim Chase:
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
Op 09-03-15 om 12:17 schreef Tim Chase:
> 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
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 b
Op 09-03-15 om 11:37 schreef Wolfgang Maier:
> On 03/09/2015 11:23 AM, 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
On 03/09/2015 11:23 AM, 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
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
--
Antoon Pardon
--
https://mail
25 matches
Mail list logo