emacs-devel
[Top][All Lists]
Advanced

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

Re: rx.el sexp regexp syntax


From: Pierre Neidhardt
Subject: Re: rx.el sexp regexp syntax
Date: Mon, 28 May 2018 18:36:28 +0200
User-agent: mu4e 1.0; emacs 26.1

Stefan Monnier <address@hidden> writes:

> FWIW, I find it's cumbersome in RX to define regexps piecewise.
> E.g. with strings I can do things like:
>
>     (let* ((word-re "\\(?:\\sw\\|s_\\)+")
>            (spc-re "[ \t\n]*")
>            (re1 (concat spc-re "\\(" word-re "\\)" spc-re))
>            (re2 (concat spc-re "\\(" word-re "\\)(" word-re))))
>
> but do the same with RX you need something like:
>
>     (let* ((word-re (rx ...))
>            (spc-re (rx ...))
>            (re1 (rx-to-string `(... ,spc-re ... ,word-re ...)))
>            (re2 (rx-to-string `(... ,spc-re ... ,word-re ...))))
>
> I think `rx` would benefit from allowing to refer to variables.

Not sure what you are trying to do, but doesn't it work with

        (rx (... (eval VARIABLE) ...))

?

--
Pierre Neidhardt

Attachment: signature.asc
Description: PGP signature


reply via email to

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