• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: RegExps in AS
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RegExps in AS


  • Subject: Re: RegExps in AS
  • From: has <email@hidden>
  • Date: Sun, 20 Feb 2005 20:49:27 +0000

Ihar 'Philips' Filipau wrote:

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.

on stripExt(filename)
set text item delimiters to "."
if (count filename's text items) > 1 then set filename to filename's text 1 thru (text item -2)
return filename
end stripExt


stripExt("some.filename.with.extension") --> "some.filename.with"


That compared to single line of PCRE (Perl Compatible Regular Expressions) which handles all cases all the time. Not the point AS shines at.

Nope. AS's text processing facilities are extremely weak. While there are some third-party libraries and osaxen that go a little way to addressing this, for any serious data munging you're really much better off using another language like Perl or Python that's properly equipped for it.


BTW, if you're already familiar with Perl, you might consider writing your script in that rather than AS. There's a collection of application scripting modules available at:

http://search.cpan.org/~cnandor/Mac-Glue/

and a nice introduction here:

http://www.perl.com/pub/a/2004/01/23/macglue.html

HTH

has
--
http://freespace.virgin.net/hamish.sanderson/
_______________________________________________
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


  • Prev by Date: Re: RegExps in AS
  • Next by Date: Re: RegExps in AS
  • Previous by thread: Re: RegExps in AS
  • Next by thread: Re: RegExps in AS
  • Index(es):
    • Date
    • Thread