Re: RegExps in AS
Re: RegExps in AS
- Subject: Re: RegExps in AS
- From: Chris Espinosa <email@hidden>
- Date: Sun, 20 Feb 2005 09:53:01 -0800
On Feb 20, 2005, at 9:35 AM, Ihar 'Philips' Filipau wrote:
[ I have checked archives of mail list, and found nothing
interesting. If I have missed something I'd love to be pointed out in
right direction. ]
I have found is that AS is completely missing regular expression
support.
I have tried to strip extension from file name and after three
hours ended up with 20 lines of code which works most of the time.
That compared to single line of PCRE (Perl Compatible Regular
Expressions) which handles all cases all the time. Not the point AS
shines at.
In past I have explained to number of non-tech people how regexps
do work, but if someone would ask me how to do anything with text in
AS, I'd rather say "sorry pal, you can't".
How do you people do in AS simple things like: strip extension (if
file has one), strip directories from path name (if there anything to
strip), extract extension (if name has one), extract path name (if
name has one), etc.
There are sample scripts for these simple things in /Library/Scripts,
check out Finder Scripts/Trim File Names.scpt, Finder Scripts/Trim
Folder Names.scpt for samples.
You can also check out the samples at
http://www.apple.com/applescript/guidebook/sbrt/index.html
P.S. And I need this to work on standard Mac OS 10.3.x. Without
external applications please, code in question has to work on iTunes
library with thousand files - calling external applications is
un-Unixy terribly expensive.
There are several excellent RegEx scripting additions, but as you say,
they're not stock. This leaves you with the ever-popular 'do shell
script' command, which lets you do anything Unixy without calling an
external application. If you can do it in Perl or a shall script, you
can call that from AppleScript.
Chris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >RegExps in AS (From: "Ihar 'Philips' Filipau" <email@hidden>) |