Hello, I am Peter Payne, and I've got a small problem with BBedit.

Essentially, I'm trying to make a script that will convert some highlighted text -- say "we have various Gundam toys here" into an affiliate link that I need to use to track clicks and subsequent sales from that click. I've got it working quite well, although the first grouping in my replace part (where I try to put what I want to be searched for after the redirected.php?SEARCH/ part) needs some more work, so that it puts various_Gundam_toys instead of "various Gundam toys" with the spaces that will break my URL.

The Applescipt I'm using here here:

replace "(.+)" using "<a href='http://affiliates.jlist.com/click/19? url=http://www.jlist.com/redirected.php?SEARCH/\\1' target='New'>\\1</ a>" searching in selection of text window 1 options {search mode:grep, starting at top:false, wrap around:false, backwards:false, case sensitive:false, match words:false, extend selection:false}

It currently changes this

We have various Gundam toys here.

into this

We have <a href='http://affiliates.jlist.com/click/19?url=http:// www.jlist.com/redirected.php?SEARCH/various Gundam toys' target='New'>various Gundam toys</a> here.

This won't work though because "various Gundam toys" after my SEARCH/ part needs to be changed to "various_Gundam_toys."

I have wrestled with this for days but can't figure out how I could "replace" the spaces in the first \\1 above with the "_" character.

Can anyone here point me in the right direction or give me a new direction to proceed in? I'd really love to get this working.

Reply via email to