• 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: Barry Wainwright <email@hidden>
  • Date: Sun, 20 Feb 2005 20:31:32 +0000

On 20/2/05 6:53 pm, "Christopher Stone" <email@hidden> wrote:

> 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

Since you're only checking for 3 character extensions here, why use the TIDs
at all?

if character -4 of fName = "." then set fname to text 1 thru -5 of fname

Better is to just use the tids to catch all extensions (there are sevral
popular 4 character extension, including .HTML, .PICT etc.

   if "." is in 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 {""}
   end if

--
Barry




 _______________________________________________
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