|
From: | Urs Liska |
Subject: | Re: Multiple replacements in one regular expression? |
Date: | Wed, 21 Jan 2015 14:01:35 +0100 |
User-agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 |
Am 21.01.2015 um 13:53 schrieb Johan Vromans:
On Wed, 21 Jan 2015 11:23:40 +0100 Urs Liska <address@hidden> wrote:#(set! str (regexp-substitute/global #f "&" str 'pre "\\&" 'post)) However, this approach will get quite cumbersome (and expensive) when there are numerous characters to be escaped. Therefore I'd like to know if I can "fold" them in one regular expression substitution.I don't know what implementation of regular expression matching scheme uses, but you should be able to specify a character set (group of characters) to match, capture the matching character, and replace it by itself with "\\" prepended.
Hm, it's not as easy as that because the escaping can be quite different, e.g.
"&" -> "\&" "\" -> "\textbackslash " "[" -> "{[}" etc. So what I really need is: match (&)(\)([) and replace that with (\&)(\textbackslash )({})And I would be glad if I wouldn't have to do that with individual runs of regexp-substitute.
Urs
-- Johan _______________________________________________ lilypond-user mailing list address@hidden https://lists.gnu.org/mailman/listinfo/lilypond-user
-- Urs Liska www.openlilylib.org
[Prev in Thread] | Current Thread | [Next in Thread] |