admin管理员组文章数量:1335887
I have a cell in a Google Sheet containing a single word. Let's say that word is TRILLION
.
I want to obtain the set of letters in the word, in order of first appearance. For that word, the answer would be TRILON
(suppressing the double L
and second I
).
I can get the string into array form easily enough with SPLIT(REGEXREPLACE(".", "$0 "), " ")
. Then I'm stuck.
I've tried UNIQUE
, but this fails on unsorted arrays. I've tried SORT
, but this does not appear to work on arrays in Google Sheets, contrary to the documentation's claims (the array remains unsorted)—plus I want the letters in the original order.
What I ultimately want is for each cell in a horizontal range to contain one letter from the original word, in the order of those letters' first appearances in the word.
The formula needs to continue to work even after the word is changed to a different one. (The spreadsheet will be used for a certain word puzzle and I want to be able to duplicate a template sheet for each word players try to work on.)
I have a cell in a Google Sheet containing a single word. Let's say that word is TRILLION
.
I want to obtain the set of letters in the word, in order of first appearance. For that word, the answer would be TRILON
(suppressing the double L
and second I
).
I can get the string into array form easily enough with SPLIT(REGEXREPLACE(".", "$0 "), " ")
. Then I'm stuck.
I've tried UNIQUE
, but this fails on unsorted arrays. I've tried SORT
, but this does not appear to work on arrays in Google Sheets, contrary to the documentation's claims (the array remains unsorted)—plus I want the letters in the original order.
What I ultimately want is for each cell in a horizontal range to contain one letter from the original word, in the order of those letters' first appearances in the word.
The formula needs to continue to work even after the word is changed to a different one. (The spreadsheet will be used for a certain word puzzle and I want to be able to duplicate a template sheet for each word players try to work on.)
Share Improve this question edited Nov 19, 2024 at 21:29 BigBen 50.2k7 gold badges28 silver badges44 bronze badges asked Nov 19, 2024 at 21:29 Peter HoseyPeter Hosey 96.4k15 gold badges213 silver badges372 bronze badges 1- 1 @ScottCraner I tried and it works! Why not post it as an answer? – Lime Husky Commented Nov 19, 2024 at 21:43
1 Answer
Reset to default 2UNIQUE's second argument is whether it should look across columns instead of down a row. Since the SPLIT is returning a horizontal array we need to make that TRUE:
=CONCATENATE(unique(SPLIT(REGEXREPLACE(A1,".", "$0 "), " "),1))
Now it works:
本文标签: stringGetting unique letters from a wordin orderin a spreadsheetStack Overflow
版权声明:本文标题:string - Getting unique letters from a word, in order, in a spreadsheet - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742397252a2467177.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论