• 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: Filter barcode out of a string (with grep?)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Filter barcode out of a string (with grep?)


  • Subject: Re: Filter barcode out of a string (with grep?)
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 18 Jul 2012 06:43:22 -0500

On Jul 18, 2012, at 04:14, email@hidden wrote:
You will need the scripting addition Satimage.osax 
______________________________________________________________________

Hey Bert,

I second the above suggestion, but you can also do this with a shell script.

First let's simplify Jan's script just a little and provide for multiple found items.

(Note that the Satimage.osax will throw an error if it doesn't find anything UNLESS you use 'all occurrences' in which case it will return an empty list '{}'.)

------------------------------------------------------------------------------------------------
# Satimage.osax
set theVar to "one;two;0123456789123456;tuesday;green
three;four;0123456789123456;wednesday;blue"

set barcodeFinder to find text "[^\\d]*(\\d{16})[^\\d]*" in theVar using "\\1" with regexp, string result and all occurrences

if barcodeFinder ≠ {} then
return barcodeFinder
else
return "Nothing Found!"
end if
------------------------------------------------------------------------------------------------

Now let's try a little Perl:

------------------------------------------------------------------------------------------------
set theVar to "one;two;0123456789123456;tuesday;green
three;four;0123456789123456;wednesday;blue"

set barcodeFinder to do shell script "perl -wlne 'if (m/[^\\d]*(\\d{16})[^\\d]*/) {print \"$1\"}' <<< " & quoted form of theVar

if barcodeFinder ≠ "" then
set barcodeFinder to paragraphs of barcodeFinder
end if

barcodeFinder
------------------------------------------------------------------------------------------------

--
Best Regards,
Chris

 _______________________________________________
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: 
 >RE: Filter barcode out of a string (with grep?) (From: email@hidden)

  • Prev by Date: Re: Display dialog to a remote machine via EPPC
  • Next by Date: Re: Display dialog to a remote machine via EPPC
  • Previous by thread: RE: Filter barcode out of a string (with grep?)
  • Next by thread: Re: Filter barcode out of a string (with grep?)
  • Index(es):
    • Date
    • Thread