Simple concatenation, right?

So what I’m trying to do is have a script that will take highlighted text, and add the HREF tags around the text in the clipboard.

Example: Highlight a URL http://google.com and run the applescript
I want the script to return this to the clipboard:
http://google.com

That way when I paste, it’ll be the text that I hightlighted with the HREF tags around it (with a blank target).
The quotation marks are being a pain in my butt.

I tried using ASCII Character 34, but it’s adding \ (as Craig & StefanK confirmed is correct for special characters) but it’s messing up my script results!

Hi,

In the future please keep posting to the same thread if it is the same issue. Thanks! :slight_smile:

If you can get the url on the clipboard then this is how you concatenate. You have to
escape characters like " in the string with the .

set theURL to the clipboard

set the clipboard to "<a href=\"//" & theURL & " target=\"_blank\">" & theURL & "</a>"

Cheers,

Craig

Thanks for the help Craig.
I made a few modifications to tweak your script a little, but the final product works like a charm!

set theURL to the clipboard
set the clipboard to "<a href=\"" & theURL & "\" target=\"_blank\">" & theURL & "</a>"

You’re a lifesaver!

You are very welcome.
Glad I could help.

Cheers,

Craig