• 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: Is there a way to speed this up?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a way to speed this up?


  • Subject: Re: Is there a way to speed this up?
  • From: Shane Stanley <email@hidden>
  • Date: Wed, 05 Oct 2016 11:05:42 +1100

On 5 Oct. 2016, at 10:54 am, Brian Christmas <email@hidden> wrote:

I could post the script, but it might offend.

Confuse, more likely.

Is there any list for Objective C?

There is, but trust me, you really don't want to go there.

As you're already using AppleScriptObjC, why not try that? You could use regular expressions to find the relevant paragraphs, something like this:

-- change encoding to match file
set theString to current application's NSString's stringWithContentsOfFile:(POSIX path of eachFile) encoding:(current application's NSUTF8StringEncoding) |error|:(missing value)
-- make sure match string is regex "safe"
set thePattern to (current application's NSRegularExpression's escapedPatternForString:"abc") as text
-- put a unique character at start of matching lines
set theString to theString's stringByReplacingOccurrencesOfString:(".*" & thePattern & ".*") withString:"😀$0" options:(current application's NSRegularExpressionSearch) range:{0, theString's |length|()}
-- delete all lines that don't start with the unique character
set theString to theString's stringByReplacingOccurrencesOfString:"(?m)^[^😀].*(\\n|\\r)*" withString:"" options:(current application's NSRegularExpressionSearch) range:{0, theString's |length|()}
-- delete the unique character at the beginning of lines
set theString to theString's stringByReplacingOccurrencesOfString:"(?m)^😀" withString:"" options:(current application's NSRegularExpressionSearch) range:{0, theString's |length|()}
-- strip trailing returns/linefeeds
set theString to theString's stringByTrimmingCharactersInSet:(current application's NSCharacterSet's whitespaceAndNewlineCharacterSet())
-- convert to paras of AS text
set theParas to paragraphs of (theString as text)

It assumes you don't have any existing paragraphs starting with ðŸ˜€.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Is there a way to speed this up?
      • From: Brian Christmas <email@hidden>
References: 
 >Re: Is there a way to speed this up? (From: has <email@hidden>)
 >Re: Is there a way to speed this up? (From: Brian Christmas <email@hidden>)

  • Prev by Date: Re: Is there a way to speed this up?
  • Next by Date: Re: Is there a way to speed this up?
  • Previous by thread: Re: Is there a way to speed this up?
  • Next by thread: Re: Is there a way to speed this up?
  • Index(es):
    • Date
    • Thread