StrReplace and double quotation Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
millansoft
Posts: 47
Joined: 19 Aug 2016, 10:10

StrReplace and double quotation

Post by millansoft » 08 Dec 2022, 23:20

Hello,

I have the following:

Code: Select all

DBXML := StrReplace(DBXML, clon[1], clon[2])
I need that it searches for example a color and replace for another one, clon[1]="red" and clon[2]"blue"

But I need to be included in the search & replace the doble quotation "red"

I´m struggling with that part, anyone knows how to do that?

Thanks.

User avatar
boiler
Posts: 16902
Joined: 21 Dec 2014, 02:44

Re: StrReplace and double quotation  Topic is solved

Post by boiler » 09 Dec 2022, 00:18

I take it that you mean clon[1] actually contains just red, but you want to search for "red" and replace it with "blue", where clon[2] contains blue.

Code: Select all

DBXML := StrReplace(DBXML, """" clon[1] """", """" clon[2] """")
Or:

Code: Select all

DBXML := StrReplace(DBXML, Chr(34) . clon[1] . Chr(34), Chr(34) . clon[2] . Chr(34))
Or:

Code: Select all

q := Chr(34)
DBXML := StrReplace(DBXML, q . clon[1] . q, q . clon[2] . q)

Demo:

Code: Select all

DBXML = Roses are "red", not red
clon := StrSplit("red,blue", ",")
DBXML := StrReplace(DBXML, """" clon[1] """", """" clon[2] """")
MsgBox, % DBXML

millansoft
Posts: 47
Joined: 19 Aug 2016, 10:10

Re: StrReplace and double quotation

Post by millansoft » 10 Dec 2022, 21:42

Works perfect, thanks a lot :)

Post Reply

Return to “Ask for Help (v1)”