?
Solved

Email parser from HTML

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

764 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