How to get the first letter from each word in mail?

Hi there,

I have a task where I have to get the first letter from the name and the two first letters from the family name from an email.

I have two mail formats:

john.doe@gmail.comJDO
john.doe-doe@gmail.comJDD

How can I achieve this, I assume I have to use an IF activity to check the format and then a Substring but don’t know the real code to write for it ?

hey
if strVar.contains(“-)”
then
strVar.substring(strVar.indexof(0))+strVar.substring(strVar.indexof(“.”)+1)+strVar.substring(strVar.indexof(“-”)+1)
else
strVar.substring(strVar.indexof(0))+strVar.substring(strVar.indexof(“.”)+1,2)
where strVar is a string variable where you can store email
Try this it will work
thanks

Thank you for your time.

I’m having this error :

hey,
why are you keeping in {} Bracket
just keep in Assign
strFinal=strVar.substring(strVar.indexof(0))+strVar.substring(strVar.indexof(“.”)+1)+strVar.substring(strVar.indexof(“-”)+1)
you will get jdd as output of strFinal.
thanks

Hey
use this workflow
Main (1).xaml (9.5 KB)
it will work
thanks

I just made a slight modification, and it worked, thank you :slight_smile:

strMailSender(0)+strMailSender(strMailSender.IndexOf(“.”)+1)+strMailSender(strMailSender.IndexOf(“.”)+2)
and
strMailSender(0)+strMailSender(strMailSender.IndexOf(“.”)+1)+strMailSender(strMailSender.IndexOf(“-”)+1)

How can I check if the “-” exists only before the “@” ?

For emails with this format : john.doe-doe@company-name.com

hey,
you can use
strVar.Substring(0,strVar.IndexOf(“@”)).Contains(“-”)
thanks

1 Like

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