[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Use the characters "+" and "-" in regular expressions
From: |
tomas |
Subject: |
Re: Use the characters "+" and "-" in regular expressions |
Date: |
Wed, 19 May 2021 21:10:30 +0200 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
On Wed, May 19, 2021 at 11:39:46AM -0500, Skip Montanaro wrote:
> > > Yes, use character sets, e.g. [+] and [-].
>
> > Plus "+" is special. Minus "-" is not.
> ...
> > Or escape with backslash. Note that due to string syntax you need
> > two of them.
>
> Yes, correct you are, Tomas. I long ago got used to putting most
> punctuation in character sets regardless of its specialness, if for no
> other reason than to help them stand out when rereading the code
> later [...]
Right: brackets help curbing the multiplication of backslashes.
I've found another strange application for that: "ps waux | grep foo"
will find your "grep foo" in the process list. Decorating one of your
characters in "foo" with brackets will fix that. Hacky, but it works :)
Cheers
- t
signature.asc
Description: Digital signature
- RE: [External] : Use the characters "+" and "-" in regular expressions, (continued)
- RE: [External] : Use the characters "+" and "-" in regular expressions, Drew Adams, 2021/05/20
- Re: [External] : Use the characters "+" and "-" in regular expressions, Jean Louis, 2021/05/21
- Re: [External] : Use the characters "+" and "-" in regular expressions, Jean Louis, 2021/05/20
- Dash in regexp character classes: Beginnig vs. end [was: Use the characters "+" and "-" in regular expressions], address@hidden, 2021/05/20
- Re: Dash in regexp character classes: Beginnig vs. end [was: Use the characters "+" and "-" in regular expressions], Robert Pluim, 2021/05/20
- RE: [External] : Re: Use the characters "+" and "-" in regular expressions, Drew Adams, 2021/05/19
- RE: [External] : Re: Use the characters "+" and "-" in regular expressions, Drew Adams, 2021/05/19
Re: Use the characters "+" and "-" in regular expressions, tomas, 2021/05/19
RE: [External] : Use the characters "+" and "-" in regular expressions, Drew Adams, 2021/05/19