Google-sheets – Delete duplicate text within a cell

google sheets

I've got cells in a column populated with data pulled from another tab using A1= Results_ES!C1 and A2= Results_ES!C2 etc.

Some of the data is duplicated whithin the cell, e.g.

Cell A1= Black Black

Cell A1 = White White

…and so on.
Basically, there's a line-break – char(10) – between each color so the first example (cell A1) in fact looks like this:

Black
Black

I'd like to keep only one appearance of each color, i.e., A1= Black
Ideally, I´d like the processing to happen automatically. In other words, I'd like to open the document and find it already corrected for me without having to manually run scripts.

I found some commands that might help such as LEFT, RIGHT, MID, TRIM, LEN, FIND, SEARCH, SUBSTITUTE, REPT, etc., but they are generally used to work with two different cells, not within a single cell. How can I accomplish this?

Best Answer

This worked on both your examples:

=REGEXEXTRACT(A1,"\w+")