• 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: Jim Underwood <email@hidden>
  • Date: Mon, 13 Mar 2017 16:25:22 +0000
  • Thread-topic: collectdata

Julien et al,

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.

This returns a _javascript_ array (aka list) with each RegEx Capture Group.

Also, I have found Regex101.com to be a great resource in developing and testing RegEx.
For this example, see https://regex101.com/r/onh0p6/1

BTW, in theory, according to Apple, you should be able to do in JXA what you have done in AppleScript.
For more info, see JXA Resources. 



'use strict';

(function run() { // this will auto-run when script is executed

/*

  REQUIRES:

    • macOS 10.11+

*/


var sourceStr = `

ABCD-123abc

Some text ABCD-abc234 some other text

ABCD-76y65yj90

ABCD-76yABC90 some text ABCD-code6547AA

`

var regEx = /(ABCD\-[^\s]+)/g;

var captureList = [];

var matchResults;


while (matchResults = regEx.exec(sourceStr)) {

   captureList.push(matchResults[1]);

}

return captureList



} // END of function run()

)();


//--- RESULTS ---

/*

["ABCD-123abc", "ABCD-abc234", "ABCD-76y65yj90", "ABCD-76yABC90", "ABCD-code6547AA"]

*/





Best Regards,

Jim Underwood
aka JMichaelTX


From: <applescript-users-bounces+jmichael=email@hidden> on behalf of Julien Battist <email@hidden>
Date: Mon, Mar 13, 2017 at 10:24 AM
To: Shane Stanley <email@hidden>
Cc: "ASUL (AppleScript)" <email@hidden>
Subject: Re: collectdata

Coming back on regular expressions I would appreciate some feedback on the following.
In indesign I can grab data in a 'cell of a kolom' using a regular _expression_ where the first 5 characters are unique and the rest is grabbed being data in the same cell.
 
In a pdf this is separated with a space or a tab or even with nothing.
 
So what I want to grab is the following in bold: 
ABCD-123abc
Some text ABCD-abc234 some other text
ABCD-76y65yj90
ABCD-76yABC90 some text ABCD-code6547AA
----
 
ABCD- is fixed the rest can be random. What would be the right regular _expression_ for this?
 
Many thanks for any feedback,
Julien
 _______________________________________________
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: collectdata
      • From: Shane Stanley <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>)

  • Prev by Date: Re: collectdata
  • Next by Date: Re: Differences in output between AppleScript and Terminal
  • Previous by thread: Re: collectdata
  • Next by thread: Re: collectdata
  • Index(es):
    • Date
    • Thread