StrReplace - escaping doublequotes failing - why? Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dwilbank
Posts: 43
Joined: 15 Mar 2020, 12:59

StrReplace - escaping doublequotes failing - why?

Post by dwilbank » 27 Jan 2023, 02:51

So I'm trying to change the language text here by targeting the "en-US" with its actual surrounding quotes as well as adding in "ko" with its actual surrounding quotes

<tt xml:lang="en-US" ...

Code: Select all

newXML := StrReplace(theXML, "xml:lang=""en-US"", "xml:lang=""ko"")
newXML := StrReplace(theXML, "xml:lang=""en-US"", "xml:lang=""ko""")
Both of these fail though, with AHK's error saying that ko is somehow being read as an illegally named variable

Is there some other way to escape these?

gregster
Posts: 9024
Joined: 30 Sep 2013, 06:48

Re: StrReplace - escaping doublequotes failing - why?  Topic is solved

Post by gregster » 27 Jan 2023, 03:00

Afaics, you have in both cases no closing quote in the second parameter, the Needle. Try
newXML := StrReplace(theXML, "xml:lang=""en-US""", "xml:lang=""ko""")

Code: Select all

newXML := StrReplace(theXML, "xml:lang=""en-US""", "xml:lang=""ko""")

dwilbank
Posts: 43
Joined: 15 Mar 2020, 12:59

Re: StrReplace - escaping doublequotes failing - why?

Post by dwilbank » 27 Jan 2023, 03:07

The old triple-quote conundrum again.
Thanks sir!

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

Re: StrReplace - escaping doublequotes failing - why?

Post by boiler » 27 Jan 2023, 05:13

dwilbank wrote: The old triple-quote conundrum again.
Instead of thinking of it as triple quotes, just think that you need a quote at the start and end of your string, and anywhere inside that where you want a quote character, you need two of them. Trying to remember special cases where there are three in a row is unnecessary and just makes it confusing.

Post Reply

Return to “Ask for Help (v1)”