How to Get First Letter of every word in a String


I have some problem, i have to abbreviation a random string (First Name Of String). that string has to become output ‘FNOS’.
anyone has idea or any sequence handle it. please inform me.



Hi @aliaga
Is that always the format ?

cheers :smiley:

Happy learning :smiley:

1 Like

Hi @aliaga try like this first split the string using space and then you will get array of words you will get once you get the word then use substring to get the first character from that word and keep looping that words.


Try with the following code,

"First Name of string".Split(" "c).[Select](Function(x) x.ToUpper.First()).ToArray()


strVar= “First Name Of String”

OutString=strVar.Split(" “c)(0).ToString.Substring(0,1)+strVar.Split(” “c)(1).ToString.Substring(0,1)+strVar.Split(” “c)(2).ToString.Substring(0,1)+strVar.Split(” "c)(3).ToString.Substring(0,1)

1 Like

Hi @pattyricarte,
yes always took one letter in front of word.

1 Like

Hi @kalyanDev,

i see, ill aply it later on my workflow.


Hi @monika.c ,

as i understand, this code split sentence string by " " and take first character from each word. am i right?



Ok That’s easy we just need to split the string delimited by spaces and get the first character. @aliaga

Please see this article below for your reference.

cheers :smiley:

Happy learning :smiley:

Having the same issues, any idea on if I don’t know how many words there will be?
I used:
variable.split(" “c)(0).ToString.Substring(0,1) + variable.Split(” "c)(1).ToString.Substring(0,1)
which works if I only have two words in my variable but how can I make it dynamic so it would take the first letter of each word no matter how many words are in the string variable?

Further up the thread there is already an answer that will handle as many or as little as you want. It is here: How to Get First Letter of every word in a String - #4 by sarathi125

As-is, that code will return an array of strings, where each string is just the first character. If you want it to be a single string at the end, then just append a .Join() at the end of it

Thank you Dave!
You mean like so:
var106DeathCity.Split(" "c).[Select](Function(x) x.ToUpper.First()).ToArray().Join()
This is giving me a complier error =(.
How can I turn the array to string?

Sorry it is actually joining it already, so the join is completely unnecessary. The original answer provided by @sarathi125 works as-is

That worked perfectly.

Thank you!!

Hi ,

I want to fetch out first 3 letters of surname frome email for example
Email address can be any it keeps on changing

Hello @shasgoel ,

Assuming the surname be always after the “.” in the mail ID,
arrValues= strTest.Split({“.”},StringSplitOptions.None)

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.