How to split string to select name initials


I am having some difficulty with splitting text.

I have a name and I need to create a username for said person.

For instance, if the persons name is: pedro riberi mandacaru, his login would have to be pedro.r.mandacaru.

Can anyone help me out with that?



You can do this multiple ways. I’m sure somebody else have an better way to do this.

Way I did it:

  1. I split the your name string to array using space delimiter.

vName = “pedro r mandacru”

vFirstLetter = Split(vName.ToString," ")

  1. Assign each letter to its own variable.

vFirstName = vFirstLetter(0)
vMiddleName = vFirstLetter(1)
vLastName = vFirstLetter(2)

  1. Get the first character from Middle Name.

vFirstCharOfString = StringInfo.GetNextTextElement(vMiddleName, 0)

  1. Then I combine the string to get your username.

vUserName = vFirstName + “.” + vFirstCharofString +“.” + vLastName

1 Like

lets take it with single expression like this
if str_input = “pedrp riberi mandacaru”

str_output = Split(str_input," “)(0).ToString+”.“+Split(str_input,” “)(1).ToString.SubString(0,1)+”.“+Split(str_input,” ")(2).ToString

so the output would be like
str_output = “pedro.r.mandacaru”

hope this would help you
Cheers @gabimlobo