t56k
t56k

Reputation: 6981

Applescript: string might have a quote

I've got an Applescript file that in part of it checks an API for a string. That string may have a quote in it. When it doesn't the script works fine, when it does have a quote the string fails. How can I safeguard the string so it works in either case?

This works:

string = "Yeah working"

This doesn't:

string = "Yeah I'm working"

How can I escape that quote mark when I don't know where it'll be or if it'll be there?

Upvotes: 0

Views: 69

Answers (1)

McUsr
McUsr

Reputation: 1409

string isn't a legal variable name for starters. Other than that, set myString to quoted form of "Something own's a quote" should do the trick.

Upvotes: 1

Related Questions