Hi!
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?
thanks!
Birdi
(Harwinder Birdi)
2
Hi,
You can do this multiple ways. I’m sure somebody else have an better way to do this.
Way I did it:
- I split the your name string to array using space delimiter.
vName = “pedro r mandacru”
vFirstLetter = Split(vName.ToString," ")
- Assign each letter to its own variable.
vFirstName = vFirstLetter(0)
vMiddleName = vFirstLetter(1)
vLastName = vFirstLetter(2)
- Get the first character from Middle Name.
vFirstCharOfString = StringInfo.GetNextTextElement(vMiddleName, 0)
- Then I combine the string to get your username.
vUserName = vFirstName + “.” + vFirstCharofString +“.” + vLastName
1 Like
Fine
lets take it with single expression like this
if str_input = “pedrp riberi mandacaru”
then
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
2 Likes