Reputation: 1106
I'm getting a report with multiple lines, e.g :
Row 1 20170719-5749-MMFF1FHDKS-23
Row 2 20170717-5749-MMYG8GBTGK-23
Row 3 20170719-5749-ML2Y7HYLJ3-9
and I would like to extract for each, MMFF1FHDKS, MMYG8GBTGK, ML2Y7HYLJ3 and so on, add them in a array and also in the clipboard as text in this format :
MMFF1FHDKS, MMYG8GBTGK, ML2Y7HYLJ3
I know I have to use text delimiter but how can I get this value which are random ?
For information the numbers are not always the same, the number of row is random and the sender can't change the format of the report.
Upvotes: 0
Views: 414
Reputation: 285082
Assuming there are always 3 hyphens in each line and the requested string is right before the last hyphen you can use
set theRows to "20170719-5749-MMFF1FHDKS-23
20170717-5749-MMYG8GBTGK-23
20170719-5749-ML2Y7HYLJ3-9"
set theResult to {}
set {TID, text item delimiters} to {text item delimiters, "-"}
repeat with row in (get paragraphs of theRows)
set end of theResult to text item 3 of row
end repeat
set text item delimiters to ", "
set the clipboard to theResult as text
set text item delimiters to TID
Upvotes: 1