Reputation: 741
how do I display the first letter of each word in let's say cell A1:
Example:
A1= Foo bar
A1= Foo
in the first example, I want to display "Fb"
in the second example, I want to see "F"
If A1 = empty I don't want to show anything
I tried this:
=REGEXEXTRACT(A1;"^.")
that shows only the first letter
Upvotes: 4
Views: 8273
Reputation: 1
the true array formula would be:
=ARRAYFORMULA(IF(LEN(A1:A);
SUBSTITUTE(TRANSPOSE(QUERY(TRANSPOSE(IFERROR(REGEXEXTRACT(SPLIT(A1:A; " ");
"\b[\w]"))); ; 999^99)); " "; ); ))
Upvotes: 4
Reputation: 201388
How about this? Please think of this as just one of several answers.
=IF(A1="","",JOIN("",ARRAYFORMULA(REGEXEXTRACT(SPLIT(A1," "),"\b[\w]"))))
""
and the first letters of each word are put, respectively. SPLIT
.REGEXEXTRACT
and ARRAYFORMULA
.
\b[\w]
was used.JOIN
.If this was not the result you want, I apologize.
As an other, it uses LEFT
instead of REGEXEXTRACT
.
=IF(A1="","",JOIN("",ARRAYFORMULA(LEFT(SPLIT(A1," ")))))
Upvotes: 8