RegexReplace: percent sign Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Galaxis
Posts: 73
Joined: 04 Feb 2016, 20:09

RegexReplace: percent sign

Post by Galaxis » 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.

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!

User avatar
mikeyww
Posts: 26599
Joined: 09 Sep 2014, 18:38

Re: RegexReplace: percent sign  Topic is solved

Post by mikeyww » 03 Dec 2021, 17:37

Code: Select all

Text = 
( LTrim %

	(1) Old:	
	(2) Older	
	(3) Old=	
	(4) Old:=	
	(5) %Old%	
	
)
MsgBox % Text := RegExReplace(Text, "Old", "New")
Explained: Percent sign

Galaxis
Posts: 73
Joined: 04 Feb 2016, 20:09

Re: RegexReplace: percent sign

Post by Galaxis » 03 Dec 2021, 21:18

@mikeyww
Dude! You're the best! Thank you!

Post Reply

Return to “Ask for Help (v1)”