Jump to content

Recommended Posts

Hi all

 

I have some bunch of data like this.

 

askdhasdkf[sld[askfsdjflasjdajjdljkd;askd;ad[addjljdlaldajdjad "jshdkjshdsd@gmail.com" sajdkasjdlsjd dsakdhal sjdlasjdksajdjsapj kdpsoakdpoa skdklasdsa daddasd dadsadj asjdoijdo; iqwueiqe pqjlnd sandsahdsj dghkjshd kadsadsakhdkjsahdkjd.

 

In the above paragraph there is a email id "jshdkjshdsd@gmail.com". I want to get that email id. I am not using database.

 

Is there any possibility to get that email id from that paragraph using php.

 

Kindly tell me ASAP. Its urgent.

 

Thanq

Link to comment
https://forums.phpfreaks.com/topic/117121-solved-get-email-id-from-bunch-of-data/
Share on other sites

Not sure what you mean compare. If you paragraph is contained in the variable $string then run it through the preg match function as per the code example.

Working code:

 

$string = "askdhasdkf[sld[askfsdjflasjdajjdljkd;askd;ad[addjljdlaldajdjad \"jshdkjshdsd@gmail.com\" sajdkasjdlsjd dsakdhal sjdlasjdksajdjsapj kdpsoakdpoa skdklasdsa daddasd dadsadj asjdoijdo; iqwueiqe pqjlnd sandsahdsj dghkjshd kadsadsakhdkjsahdkjd.";
if(preg_match('/\\b([a-zA-Z0-9._%-]+@(?:[a-zA-Z0-9-]+\\.)+[a-zA-Z]{2,4})\\b/', $string, $matches)) {
	print "I have found the email address: ".$matches[0];
}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.