[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
signature.asc
Description: PGP signature
- Re: rx.el sexp regexp syntax, (continued)
- Re: rx.el sexp regexp syntax (WAS: Off Topic), Alan Mackenzie, 2018/05/25
- Re: rx.el sexp regexp syntax, Michael Heerdegen, 2018/05/25
- Re: rx.el sexp regexp syntax, Peter Neidhardt, 2018/05/25
- Re: rx.el sexp regexp syntax (WAS: Off Topic), Peter Neidhardt, 2018/05/25
- Re: rx.el sexp regexp syntax, Tom Tromey, 2018/05/27
- Re: rx.el sexp regexp syntax, Alan Mackenzie, 2018/05/27
- Re: rx.el sexp regexp syntax, Stefan Monnier, 2018/05/27
- Re: rx.el sexp regexp syntax, Stefan Monnier, 2018/05/27
- Re: rx.el sexp regexp syntax,
Pierre Neidhardt <=
- Re: rx.el sexp regexp syntax, Stefan Monnier, 2018/05/28