How can I extract only email ID from a string

Hi All,

Hope all are doing good.
I want to fetch only the email address from the below string:

Please use the following address to contact me john.doe@localcompany.com on the company email.

the string is dynamic and I dont wanna use the regex to achieve this.

Please do the needful.

thanks

Hey @naveen.s
try to use:
emailAddress = inputString.Split(" "c).Where(Function(s) s.Contains("@") AndAlso s.Contains(".")).FirstOrDefault()

Hi,

Can you try to use FindMatchingPattern activity as the following.
There is email pattern and FirstMatch property returns first match string.

Regards,

Hi @naveen.s

inputString.Split(" "c).Where(Function(x) x.Contains("@")).FirstOrDefault()

Regards

Hi @naveen.s

Try this

Input="Please use the following address to contact me john.doe@localcompany.com on the company email."
Input.Split(" "c)(Array.FindIndex(Input.Split(" "c), Function(x) x.Contains("@")))

Cheers!!

Hi @naveen.s

Try below Regex Expression:

System.Text.RegularExpressions.Regex.Match(InputString," [a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}").Value

Hope it will helps you :slight_smile:
Cheers!!

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