• 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: collectdata
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: collectdata


  • Subject: Re: collectdata
  • From: Shane Stanley <email@hidden>
  • Date: Tue, 14 Mar 2017 15:56:52 +1100

On 14 Mar 2017, at 3:25 am, Jim Underwood <email@hidden> wrote:
>
> This probably doesn't fit in with your overall requirements, but just as an example of how easy it is to use the JavaScript RegEx engine with JavaScript for Automation (JXA), here's a solution for just the RegEx part.

You are correct about the first part -- retrieving the matching text doesn't help with the overall problem.

Just to be clear, no-one has come up with a scriptable PDF editor that supports searching via regular expression. It's a shame, because that would be the best answer. So a solution like Thomas's, which extracts the text, does regular expression searches on it, and then does literal searches based on the results, might work in some cases -- but it might also fail. That's because you can craft the regex pattern to handle what precedes and/or follows the pattern, but once you get to the literal search part with the resulting match, you lose that control -- "ABCD-123" is always going to find the middle of "XYZABCD-123456" in a literal search.

The ASObjC solution doesn't have the same problem simply because it does a single search, and then uses the ranges of the matches returned to build the annotations.

> BTW, in theory, according to Apple, you should be able to do in JXA what you have done in AppleScript.

Yes, you should. But you would have to use NSRegularExpression, and not the JavaScript regex engine, because you need the ranges, and you need them based on NSString's concept of unichar values, not UTF-8 characters.

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


References: 
 >collectdata (From: Julien Battist <email@hidden>)
 >Re: collectdata (From: Shane Stanley <email@hidden>)
 >Re: collectdata (From: Thomas Fischer <email@hidden>)
 >Re: collectdata (From: Julien Battist <email@hidden>)
 >Re: collectdata (From: Yvan KOENIG <email@hidden>)
 >Re: collectdata (From: Christopher Stone <email@hidden>)
 >Re: collectdata (From: Thomas Fischer <email@hidden>)
 >Re: collectdata (From: Julien Battist <email@hidden>)
 >Re: collectdata (From: Shane Stanley <email@hidden>)
 >Re: collectdata (From: Thomas Fischer <email@hidden>)
 >Re: collectdata (From: Shane Stanley <email@hidden>)
 >Re: collectdata (From: Shane Stanley <email@hidden>)
 >Re: collectdata (From: Julien Battist <email@hidden>)
 >Re: collectdata (From: Jim Underwood <email@hidden>)

  • Prev by Date: Re: collectdata
  • Next by Date: Re: collectdata
  • Previous by thread: Re: collectdata
  • Next by thread: Re: collectdata
  • Index(es):
    • Date
    • Thread