[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: how to use a variable inside Emacs regex features ?
From: |
Michael Heerdegen |
Subject: |
Re: how to use a variable inside Emacs regex features ? |
Date: |
Thu, 23 May 2019 18:37:04 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
<tomas@tuxteam.de> writes:
> If you are doing more complex things, you might like 'rx', which
> allows you to write regular expressions in S-expression syntax,
> thus giving you access to template macros and all that goodness.
This is a task for rx indeed - or rx-to-string when the regexp depends
on the run-time value of a variable:
(let ((ntimes 8))
(re-search-forward
(rx-to-string `(= ,ntimes "hello"))))
Michael.