Remove the text after , (comma)

Hi, I want to remove the text after the comma, My condition is I am extracting the email I’d using the Regex, But sometimes it comes with single email I’d and sometimes comes with double email I’d. So I want to take only first email I’d. Ex. abc@gmail.com, abcd@yahoo.com, here I want to take only first email I’d which is abc@gmail.com.
But Always there is not the scenario that it will come with double email If. If it come with only single email I’d then I want to take that I’d only like Ex. abc@hotmail.com so here is single email I’d not double email I’d separate by a comma. so I want to take abc@hotmail.com.
Plz help. @lakshman @Palaniyappan @ClaytonM
@ClaytonM you already told me this case when we takes the I’d after , (comma). so can you please tell me how can I take first email I’d not after comma.

1 Like

Fine
Kindly follow the below steps that could help you solve this buddy
–hope you have the mailid values stored in a variable named in_text of type string
–use a if condition like this
in_text.ToString.Contains(",")
if this condition gets satisfied it will go to THEN part where we can get the first mail like this
out_mail = Split(in_text,",")(0).ToString.Trim
or if the above condition fails it will go to ELSE part where we can leave as it is (empty)

Cheers @balkishan

1 Like

Check if the string contains comma, and if it does, split the string by comma and get the item at position 0 in the splitted array.
something like:
if variable.contains(",") then
email = variable.split({","}, StringSplitOptions.RemoveEmptyEntries)(0)
else
email = variable

1 Like

It’s not storing in a text, it’s comes from different profile some have single email some have double email id bro.

Fine
I hope you will be fetching those mailids with some activities
Cheers @balkishan

1 Like

Exaclty bro

1 Like

Store the outcome of that activity to a string variable and go with the above steps buddy
Cheers @balkishan

1 Like

were you able to get now buddy
Cheers @balkishan

1 Like

Not worked @Palaniyappan bro
@RobertD’s solution worked!!

oh no worries
why i tired to reproduce
it worked on my side
can i have a view on the workflow if possible buddy
Cheers @balkishan

1 Like

sure bro

I gave the I/p abc@gmail.com, abcde@yahoo.com. It gave me abc@gmail.com

@Palaniyappan your solution bro

1 Like

abc@gmail.com thats the output we need right buddy
Cheers @balkishan

1 Like

sorry sorry bro, yes I need the same output. I am so sorry bro from my side. your solution is also perfect. So so sorry bro!! Actually I wrong perceived.

1 Like

Cheers @balkishan

1 Like

Thanks to @Palaniyappan and @RobertD both solutions worked. :slight_smile: :slight_smile:

1 Like

Great
Cheers @balkishan

1 Like

@Palaniyappan @RobertD
can you please help me, Above my source variable was string type. Now I am using the RegularExpression variable. so can you please tell me how to do this. Email is my regularexpression variable which contains the email address.
image

Email(0).toString will get the full group, Email(1) will get 1st match. Try the 1st one, if it returns the whole text, not only the e-mail, use the second.

you’re right bro it will give me the full text