Email Extractioin with out using Regex

Hi ,
Im trying to extract email id from the given string with out using Regex.
I’m going some where wrong in this.
Can any one help me out with this.

Given String is : “Please use the following address to contact me john.doe@localcompany.com, it’s the company email"

I used following Split method method to get email id.

givenString.Split(",“c).First.ToString.Substring(givenString.LastIndexOf(” "))

Thank in Advance.

@saritha I believe After you have splitted the String to get only the First part of the Split, You would need to use that Splitted part only for the Substring to get the Last Space in the range. Hence I believe below is the correction :

givenString.Split(","c).First.ToString.Substring(givenString.Split(","c).First.LastIndexOf(" "))
2 Likes

Hi,
It worked now.
Thank you so much.
Have a great day.

Hi,

I have a question

when we write
givenString.Split(“,“c).First.ToString we will get” Please use the following address to contact me john.doe@localcompany.com

so as givenString has “Please use the following address to contact me john.doe@localcompany.com”, we need only substring of the givenString rite.

why do we need still Split in Substring?
Didnt get this clearly.

@saritha - You can try like this…

GivenString.split(",“c).First.ToString.Split(” "c).Reverse()(0)

First Step: GivenString.split(“,“c).First.ToString ==> this will give you…” Please use the following address to contact me john.doe@localcompany.com

Second Step: Split by string by spaces and take the last , so I have used reverse(0)…

here is my write Line

image

Output:
image

1 Like

Hi
thank you for ur response.
May I know please
Second Step : you tried to split the String to get (john.doe@localcompany.com ) from the string “Please use the following address to contact me john.doe@localcompany.com
and used split(" "c) . untill that I got it clearly.

May I know how .Reverse()(0) used for… inorder to get after last space message

@saritha - “Please use the following address to contact me john.doe@localcompany.com” - when you split by spaces it will split it as

Please
Use
the
Following
address
to
contact
me
john.doe@localcompany.com

right?

So if you read from the bottom , i.e reverse()(0) - is your email ID…

If this helps, please mark this my post as solution , that will close this thread and help others in finding the solution post easily.

2 Likes

Now I’m clear with this. Thank you.

May I also know for the reverse function what we need to write it in brackets.

I mean reverse(?)(?) this one .

Thanks in advance.

@saritha - Reverse()(arrayelement) - first element leave blank…

Hi,

Now I’m pretty much clear about this.

Thank you so much.

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