How to remove \ fast from variable?

Is there faster way to remove \ from Mag-variable. After remove, script pastes that html to webform which postes it to webpage. Or is there a way to put html-code to variable without using \ before " somehow? Mag-variable is much longer in my script than in this example and it takes forever to remove.

set mag to “<p class="listitem">”

repeat with myChar in mag
set myNum to ASCII number of myChar
if myNum is 92 then set newString to newString & (ASCII character of myNum)
set mag to mag & (ASCII character of myNum)
end repeat


Try this:

set mag to "<p class=\"listitem\">"
set text item delimiters to (ASCII number 92)
set mag to (mag's text items) as Unicode text

I have a feeling that the Gurus will come up with something better…

Watch this space for more!


Hi, cirno.

What’s a Mag-variable?

There are no backslashes in that string. The ones you see (and have to write) in Script Editor are just escape codes to show that the quotes that follow them are characters in the string. The backslashes don’t occur in the string itself. See what’s displayed when you run this:

set mag to "<p class=\"listitem\">"
display dialog mag

Any backslashes that do occur in a string will appear as “\” (ie. escaped backslashes) in Script Editor, and any code you write to remove them will have to use that convention.

Mag-variable? Mag=Magazine.

Earlier i had similar code but it did show \ for some reason when i did display dialog for that variable.

BTW, is there any software that is freeware and keeps applescripts in ram-memory and user can launch these scripts using keyboard?


Hey, you’re welcome. :confused:


Hope this helps.
Use myChar as string. I think myChar is not coersed as a string when you use it in the repeat with statement.
So it would be:

if myChar as string is “\” then set newString to newString & “whateveryouwantedtochange”

Good luck