[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Improve `replace-regexp-in-string' ergonomics?
From: |
Lars Ingebrigtsen |
Subject: |
Re: Improve `replace-regexp-in-string' ergonomics? |
Date: |
Wed, 22 Sep 2021 22:22:13 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> It'd be nice to have a front-end that lets you write a kind of lex-like
> set of rules, but I think it'd be important for that front-end to allow
> *computing* the replacement rather than only selecting it based on the
> matched regexp. Something like
>
> (foo-replace results
> ("\\[" "(")
> ("\\]" ")")
> ("[[:lower:]]+" (upcase (match-string 0)))
> ("siglo \\([0-9]+\\)"
> (integer-to-roman (string-to-number (match-string 1))))
> ...)
Perfect. That looks like a really nice function signature to me.
Perhaps without the parentheses if there's only one replacement to be
done.
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
- Re: Improve `replace-regexp-in-string' ergonomics?, (continued)
Re: Improve `replace-regexp-in-string' ergonomics?, Lars Ingebrigtsen, 2021/09/22
Re: Improve `replace-regexp-in-string' ergonomics?, Dmitry Gutov, 2021/09/22
Re: Improve `replace-regexp-in-string' ergonomics?, Stefan Monnier, 2021/09/22