String replacement or How I stopped Worrying and learned to Love Perl
String replacement or How I stopped Worrying and learned to Love Perl
- Subject: String replacement or How I stopped Worrying and learned to Love Perl
- From: Daniel Lord <email@hidden>
- Date: Tue, 14 Jan 2003 22:22:58 -0800
Folks,
Rather than contort Applescript into doing unnatural things let it do
what it does best and use Perl for what it does best as I have learned
to do:
set regexp to "'s/\\.util//g;print;'"
set s to
"Gnarlodious.util:Workshop.util:Forth.util:Mops.util:MopsManual.util:"
set shellCmd to "echo " & s & " | perl -ne " & regexp
set x to do shell script shellCmd
Works every time ;-) And better yet you can use very complex regex
subs and even match variables like \1 \2 etc. I even wrote a recursive
file renamer and mover using a Python script to do the regex and
recursive directory walking and wrapping it in Applescript Studio to
provide a GUI. The combination Python-AS was much faster than doing it
all in Applescript alone. Only on OS X can you do this and that is its
true power.
Daniel Lord
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.