bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnulib-tool.py: Simplify regular expressions.


From: Bruno Haible
Subject: Re: gnulib-tool.py: Simplify regular expressions.
Date: Thu, 11 Apr 2024 23:54:22 +0200

Hi Collin,

> > Oh, this means that r'[x\$]' contains dollar and backslash, whereas the
> > programmer might have thought that it contains only the dollar? Indeed,
> > it's worth to listen to these warnings!
> 
> I don't think it changes the meaning:
> 
>     import re
>     re.match(r'[x$]*', 'x\\$').group()
>     'x'
>     re.match(r'[x\$]*', 'x\\$').group()
>     'x'
>     re.match(r'[x\\$]*', 'x\\$').group()
>     'x\\$'

Oh, so it's not as bad as I thought. I had taken your statement

  "And in the set the special characters have their special meaning dropped,
   so there is no need to backslash them."

at face value, and got confused. Actually the correct statement is

  "And in the set the special characters, other than backslash, have their
   special meaning dropped,
   so there is no need to backslash them."

Bruno






reply via email to

[Prev in Thread] Current Thread [Next in Thread]