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
Solved

Email parser from HTML

Posted on 2011-02-12
1
238 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
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Help with PHP 13 27
selector:validator cookies 4 30
Row insertion failed. Array 5 46
Inserting data into database 10 34
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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 is …
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.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

840 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