Paste the name of an email

I have a process in which the imput are e-mails. With sender the name of the one sending the mail appears to me in the order first name and last name. I need to paste that information into an application in the reverse order, i.e. first the last name, comma and first name. How can I do it?

I already have an approximate solution that is separating with Split by spaces, but it is a problem because sometimes the first name is composed.

1 Like

Hello @Marisa_Ontiveros

Assuming your value(name) you get is in Proper Case format (first letter is capital for e.g like this MarisaOntiveros or Marisa Ontiveros).

Assign this code to a String Datatype variable

Strrr.Select(Function(r) If(System.Text.RegularExpressions.Regex.IsMatch(Strrr,"(?=[A-Z])\B\w+")=True,System.Text.RegularExpressions.Regex.Match(Strrr,"(?=[A-Z])\B\w+").ToString+","+System.Text.RegularExpressions.Regex.Match(Strrr,"(?=[A-Z])\w+(?=[A-Z])").ToString,String.Join(",",System.Text.RegularExpressions.Regex.Matches(Strrr,"\w+").Cast(Of match).Reverse) ) )(0)

Explanation…

  1. here Strrr is my string variable replace it with your’s

using this code it’ll check the what kind of name we have whether is has space in between or composed and
if its composed then my Regex pattern will get the two values based on the Captial letters of each word and then it’ll rearrange the order and also add a comma to it.
If it has space in between it’ll just get the two words using regex and reverse the order and add a comma.In the end (0) is to get the first value as we had split it using each character.

Check this workflow for better understanding

marisa.zip (12.9 KB)

1 Like

It doesn’t work well for me at all. If the name is for example Maria Luisa Ontiveros Gonzalez I need Ontiveros Gonzalez, Maria Luisa and for example if the name is Marta Lopez Castilla I need Lopez Castilla, Marta. With the formula that you propose gives me Gonzalez, Ontiveros, Luisa, Maria and so the application does not allow me. Thanks a lot.

1 Like

Se podría hacer utilizando una variable tipo lista y el método count?

Could it be done using a list type variable and the count method?

splitName.xaml (15.3 KB)

I have tested with the following inputs,

  1. Maria Luisa Ontiveros Gonzalez --> Ontiveros Gonzalez, Maria Luisa
  2. Marta Lopez Castilla --> Lopez Castilla, Marta
  3. Marta Lopez --> Lopez, Marta

Please have a look…! @Marisa_Ontiveros

Thanks!

2 Likes

This solution works for me. Thank you so much.

1 Like

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