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
|