copy paste – applecript: add clipboard content to the list

Let's say that my clipboard is "email phone name" and any text and random numbers.
Can the words To be separated and added to a list?

You do not realize, but you have answered your own question.


Let's say that your clipboard contains the string "Kevin 124098". Separate this into a list of words like this:

words from (the clipboard) -> {"Kevin", "", "124098"}

You can read more about this integrated AppleScript feature below, where I have given a detailed explanation, including why, unfortunately, this will not be as effective if it is an email address:

words from "" -> {"Kevin", ""}

So you should remember to restore the deletion. "@" symbol after or, as you suggested, use delimiters of text elements set in a space character.

Detailed information: delimiters of text elements vs words

AppleScript text the objects are made up of word Y character elements that are subdivided into each other in the building blocks of any chain components: text subdivide in words I characters; a word subdivide in characters.

Besides, the words subdivide text at intervals marked by blanks of any length, which is much more convenient than delimiters of text elements, which will split a string in each individual occurrence of a specific delimiter.

For example, the configuration delimiters of text elements to the space character, and applying it to a two-word phrase with three spaces between them, will end with this:

"foo bar" text elements -> {"foo", "", "", "bar"}

However, getting instead words that make up the chain avoids having to deal with empty string list elements:

words from "foo bar" -> {"foo", "bar"}

On the other hand, as text elements, words of a text The object will subdivide the string naturally into a list of individual elements.

To complete, I will quickly demonstrate how characters a chain will decompose:

"foo" characters -> {"f", "o", "o"}
"foo bar" characters -> {"f", "o", "o", "", "", "," b "," a "," r "}

A little caution is required when breaking a chain into words, believing that it works identically (or close enough) to a space delimiter Does not There is a defined set of characters that are considered "character of words" and a set of characters that are not. The "word characters" are any character that, when grouped together, are considered word formers. If a non-word character appears, the word is considered divided into two different words in that character.

The characters of the words basically include the letters A-Z and a-z (and any accented variant), the numbers 0-9, the point (.) and the underscore (_). So "tH1s" it's a word, and "this_is_a_single_word.123". But nevertheless, "this # is% four words", and, counterintuitively for me, "surpassing" it is considered two words (the script is a character without a word).

Other characters that are not words obviously include space; or any blank space for that matter. In addition to any symbol that you can type with your keyboard that was not included in the list of word characters, except the dollar sign ($), which bothers me to mention now to reflect how annoying it is to randomly consider a character of a word:

words of "hello # $ and world" -> {"hello", "$", "world"}