0

I have an array that contains various titles of windows. Their title is something like "... number 333999333 id ....". So the array looks like this:

array ("... number 333999333 id ....",
    "... number 333999334 id ....",
    "... number 333999335 id ....",
    "... number 333999336 id ....",
    "... number 333999337 id ....",
    "... number 333999338 id ...."
)

I'd like to use "number" and "id" as delimiters and use the number between them to create a new array (or modify the existing one) that would contain only those numbers.

array ("333999333",
    "333999334",
    "333999335",
    "333999336",
    "333999337",
    "333999338"
)

How can I achieve that?

1 Answer 1

1

Try:

set listA to {"… number 333999333 id ....", "... number 333999334 id ....", "... number 333999335 id ....", "... number 333999336 id ....", "... number 333999337 id ....", "... number 333999338 id …."}

set listB to {}
repeat with anItem in listA
    set end of listB to do shell script "echo " & quoted form of anItem & " | sed 's/.* \\([0-9]*\\) .*/\\1/'"
end repeat

return listB
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.