• 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: "Ihar 'Philips' Filipau" <email@hidden>
  • Date: Mon, 21 Feb 2005 23:25:28 +0100


On 20 Feb 2005, at 22:02, kai wrote:


One way might be to use AppleScript's text item delimiters:

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

on part of str at pos between sep
	set text item delimiters to sep
	set str to str's text item pos
	set text item delimiters to {""}
	str
end part

set filePath to "Macintosh HD:Users:UserName:Documents:Some File.rtf"

set fullName to part of filePath at -1 between ":"
set shortName to part of fullName at 1 between "."

{fullName, shortName}

--> {"Some File.rtf", "Some File"}



Wow. That's cool.
I still have problems getting how this stuff with delimiters works. It is - together with "text" - most unintuitive piece of stuff in AS.
I have asked about RegExp, since this is normal choice for text processing for about last 20 years. PCRE are newer revised one from Perl.
All this playing around with negative indexes makes AS messy: in some places they work, in some places AS barks on them. In some places empty string is Ok, in other it is error. Mess, compared to beauty, simplicity and power of regular expressions.


But nevertheless, above quoted script works and works quite well where I need it - that's important. Thanks!

P.S. And btw "do shell script" cannot pipeline, so it is rather useless. Running new instance of say perl for 1k of files is just insane. sed/awk will run faster - but still overall is slow. Silly, especially when all this *nix stuff is designed to be pipelined. Command line? - one might easily hit limit on command line length, which in BSDs (compared to GNU) is set quite low.

--
  A civilization is built on what is required of men,
  not on that which is provided for them.
      -- Antoine de Saint-Exupery

_______________________________________________
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: kai <email@hidden>
    • Re: RegExps in AS
      • From: Doug McNutt <email@hidden>
    • Re: RegExps in AS
      • From: Andrew Oliver <email@hidden>
    • Re: RegExps in AS
      • From: John Stewart <email@hidden>
References: 
 >Re: RegExps in AS (From: kai <email@hidden>)

  • Prev by Date: Re: InDesign Search-Replace Case Problem
  • Next by Date: Re: Quark 6.5 Page Name of Group Items
  • Previous by thread: Re: RegExps in AS
  • Next by thread: Re: RegExps in AS
  • Index(es):
    • Date
    • Thread