[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Email parser from HTML

Posted on 2011-02-12
1
Medium Priority
?
259 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 1000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

656 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