Replace Quotes with Escaped Quotes in String

Brahmanathaswami brahma at hindu.org
Wed Dec 16 10:00:37 EST 2015


Sorry but this did not work:

replace "'" with "\'" in tBody
put merge("echo '[[tBody]]' | ") into tCmd
put format ("mail -s \"Visitor Care Notice\" -r \"No-Reply at hindu.org\" " 
& tAddresses) after tCmd
get shell(tCmd)

tBody = Peter is visiting Kauai from Scotland. He says "It's a great 
day...Finally I get a break from coding and get to leave this island in 
the northern hinterland and go to another one in the Pacific Blue."

email arrives with quotes stripped out.

Peter is visiting Kauai from Scotland. He says It's a great 
day...Finally I get a break from coding and get to leave this island in 
the northern hinterland and go to another one in the Pacific Blue.

Back the first question: how do we replace double quotes in a field or 
variable?

put format ("\"") into tEscapedQuote
replace quote with tEscapedQuote



Brahmanathaswami wrote:
> Ah... I see: so a string like this
>
> Peter is visiting Kauai from Scotland. He says "It's a great 
> day...Finally I get a break from coding and get to leave this island 
> in the northern hinterland and go to another one in the Pacific Blue."
>
> 1) first we escape the single quote "It\'s"
> 2) then wrap with single quotes. and the double quotes are preserved
>
> "sweet"
>
> I'll try it
>
>
>
> Peter TB Brett wrote:
>> No, single quotes and double quotes are not equivalent in LiveCode. 
>> However, the shell ignores any escape characters or " characters 
>> inside single-quoted strings.
>>
>> So, you can do:
>>
>> replace "'" with "\'" in tBody
>> put merge("echo '[[tBody]]' | ") into tCmd
>>
>> and your tBody should be protected from shell expansion.
>>
>>                                     Peter 
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your 
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the use-livecode mailing list