Page 1 of 1

StringReplace with a variable

Posted: 02 Feb 2018, 09:07
by bballjoe12
I have the following code:

Code: Select all

MsgBox, %DisplayThisText%
The %DisplayThisText% variable has text in it that includes the word 'Send.' How do I replace all instances of the word 'Send' with, let's say, with the word 'Go.' I tried looking at StringReplace but have no clue how to actually display the edited text.

Re: StringReplace with a variable  Topic is solved

Posted: 02 Feb 2018, 10:26
by Exaskryz
output:=StrReplace(inputVariable,"Send","Go")

Code: Select all

DisplayThisText:="Send something"
DisplayThisText:=StrReplace(DisplayThisText,"Send","Go") ; the inputVariable is the same as the output in this case, which is fine
MsgBox %DisPlayThisText%
or

Code: Select all

DisplayThisText:="Send something"
MsgBox % StrReplace(DisplayThisText,"Send","Go") ; we skip the output variable, but the result is still shown in the MsgBox using forced expression mode by using a lone % at the very start of the parameter

Re: StringReplace with a variable

Posted: 02 Feb 2018, 13:09
by bballjoe12
Awesome, got it figured out!