help-gnu-emacs
[Top][All Lists]
Advanced

[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

Attachment: signature.asc
Description: Digital signature


reply via email to

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