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

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

Re: (rx regexp to remove space and new lines


From: tomas
Subject: Re: (rx regexp to remove space and new lines
Date: Mon, 12 Sep 2022 12:13:14 +0200

On Mon, Sep 12, 2022 at 12:25:58PM +0300, Jean Louis wrote:
> I would like to construct rx regexp to remove both whitespace
> characters and new line "\n" to replace it with only one space " ".
> 
> How to do it?
> 
> (string-replace (rx (one-or-more (any "\n" "[[:space:]]"))) " " sql)))))

This looks about correct, so I don't understand your question. In which way
this does fail? Don't make us solve riddles ;-)

Note that [:space:] includes "\n" (and vertical tabulator and other ilks
of space-y characters), so the (any "\n" "[[:space:]]") seems redundant
and "[[:space:]]" should suffice.

I'm not very fluent on Rx, but I'd double check whether it takes "[[:space:]]"
as syntax.

Cheers
-- 
t

Attachment: signature.asc
Description: PGP signature


reply via email to

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