Hi!
I am new to AutoHotkey. I solicit your help.
I would like to replace a word with another word in a text. For example, if the word "apple" exists in a text, I would like that word to be replaced by "pear".
How should I write the programming code?
Regards!
How to replace a word with another word?
-
- Posts: 1472
- Joined: 05 May 2018, 12:23
Re: How to replace a word with another word?
Code: Select all
string := "the word is apple test script"
newString := strReplace(string, "apple", "orange")
MsgBox, % newString
ExitApp
Re: How to replace a word with another word?
Code: Select all
#Requires AutoHotkey v1.1.33
string := "The word is apple. Test my applets script."
newString1 := StrReplace(string, "apple", "orange")
newString2 := RegExReplace(string, "\bapple\b", "orange")
MsgBox % newString1 "`n" newString2