Solved

Email parser from HTML

Posted on 2011-02-12
1
244 Views
Last Modified: 2012-05-11
Can you help me with a code to extract email addresses from a HTML? The html will be pasted in the text area <textarea> . On submit it should give me email addresses separated one line after the other from the code.
0
Comment
Question by:nainil
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 34

Accepted Solution

by:
Beverley Portlock earned 250 total points
ID: 34880267
OK, Asumming that your addresses are separted by white space, I have simulated the input from the textarea in $test

<?php

$test = '
abc@example.com
de-fg@example.co.uk
shs.sksk@example.org
';

$pattern = '|\s?([-\.0-9a-z]{2,}@[-0-9a-z\.]{3,})\s?|';

preg_match_all( $pattern, $test, $matches );

print_r( $matches [1]);

Open in new window


Produces

Array
(
    [0] => abc@example.com
    [1] => de-fg@example.co.uk
    [2] => shs.sksk@example.org
)
0

Featured Post

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question