• 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: Christopher Stone <email@hidden>
  • Date: Sun, 20 Feb 2005 12:53:20 -0600

At 18:35 +0100 02/20/2005, Ihar 'Philips' Filipau wrought:

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.
______________________________________________________________________

Greetings,

I like to use the Satimage osax for regular expressions in Mac OS X.

http://www.satimage.fr/software/en/downloads_osaxen.html

(An osax is an AppleScript extension.)

----------------------------------------------------------------------

 set fName to "someFileName.ext"

set fName to change "\\.[a-z]{3}$" into "" in fName with regexp without case sensitive

----------------------------------------------------------------------

You can also shell out to perl or other languages in Mac OS X.



For a more traditional AppleScript approach you can do something like this:

----------------------------------------------------------------------

 set fName to "someFileName.ext"

 if character -4 of fName = "." then
   set AppleScript's text item delimiters to {"."}
   set fName to (text items 1 thru -2 of fName) as string
   set AppleScript's text item delimiters to {""}
   fName
 end if

----------------------------------------------------------------------


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
  • Follow-Ups:
    • Re: RegExps in AS
      • From: Andrew Oliver <email@hidden>
References: 
 >RegExps in AS (From: "Ihar 'Philips' Filipau" <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