RegexReplace: percent sign
Posted: 03 Dec 2021, 17:31
In the code below, I'm trying to change %Old% to %New% with RegexReplace. For some reason, it simply disappears. I want to read the percent signs as literal from FileAppend, or better yet, simply change the expression name without it disappearing.
I've tried this as well, but to no avail:
Text:=RegExReplace(Text, "`%Old`%","New") ;FAIL
Text:=RegExReplace(Text, "\%Old\%","New") ;FAIL
Text:=RegExReplace(Text, "%","`%") ;FAIL
Please help. Thanks!
Code: Select all
Text=
(Ltrim
(1) Old:
(2) Older
(3) Old=
(4) Old:=
(5) %Old%
)
Text:=RegExReplace(Text,"Old","New")
/*
-----------------------------<RESULTS>-----------------------------
(1) New:
(2) Newer
(3) New=
(4) New:=
(5)
*/
I've tried this as well, but to no avail:
Text:=RegExReplace(Text, "`%Old`%","New") ;FAIL
Text:=RegExReplace(Text, "\%Old\%","New") ;FAIL
Text:=RegExReplace(Text, "%","`%") ;FAIL
Please help. Thanks!