I don’t know if this is possible with AppleScript but I would really appreciate if someone could help me out with this, I need to be an applescript that takes in input through the textbox and checks if there are specific characters like @ in the text. If the input has those characters, they need to be replaced with ‘%40’. I’m making a script that uses URI and I needed help with this portion.
set textAfter to my remplace(textBefore, "@", "%40")
--=====
(*
replaces every occurences of d1 by d2 in the text t
*)
on remplace(t, d1, d2)
local oTIDs, l
set oTIDs to AppleScript's text item delimiters
set AppleScript's text item delimiters to d1
set l to text items of t
set AppleScript's text item delimiters to d2
set t to l as text
set AppleScript's text item delimiters to oTIDs
return t
end remplace
--=====
may do the job.
Yvan KOENIG (VALLAURIS, France) mercredi 16 janvier 2011 23:09:30
When using shell commands you need to excape characters. The dollar sign has a special meaning in the shell, it thinks it is a variable. So for every dollar sign you need to put an escape character in front of it (when using do shell script). A little example: $HOME is a variable in the shell to your home folder. When you try to echo in PHP for example the home folder as described below it will return the contents of the variable.
do shell script "php -r \"echo '$HOME';\""
The result is the path to your home folder. What happened was that while the command (the string of do shell script command) was interpreted by the shell’s interpreter, $HOME has been replaced by it’s value before it has been send to PHP.
so for PHP the script would look like this (PHP doesn’t have problems with @ signs)
As you see, it use my original handler to escape the special characters $ and @
then it call the powerful Perl code.
I wish to say thank you to Shane because I missed the fact that “robas” was dropped too
and to DJ Bazzie Wazzie who gave the explanation (and the way to get rid) of what was for me an odd behavior.
Yvan KOENIG (VALLAURIS, France) jeudi 17 janvier 2011 14:24:02