The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 18, 2019, 12:10:55 AM

Login with username, password and session length


Pages: [1]
  Print  
Author Topic: Extract an EMail Address  (Read 3644 times)
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« on: April 20, 2007, 09:50:22 PM »

^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}

Note that this is case sensitive as is. If for example you were doing this in PHP, you'd reference it this way:

preg_match_all('/([A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4})/i', $inputBuff, $emails);

... it's the lowercase letter I after the closing / that says "Case Insensitive." In this example we are trying to grab all emails we see in $inputBuff and put them into the array $emails.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #1 on: April 20, 2007, 11:22:22 PM »

Hi Perk,

What is this thing you call $inputBuff?  Where does it come from?  What else might be in it?


Bompa

« Last Edit: April 21, 2007, 04:27:53 AM by Bompa » Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #2 on: April 21, 2007, 12:32:16 AM »

$inputBuff is just the variable he's using in the example. So to answer your question, it would be the data that you're trying to determine if it's a valid email or not.

The parameters for preg_match_all (a PHP function) are:

1. The regex
2. The string to perform the regex on
3. The output array

More info here:

http://www.php.net/preg_match_all

Logged

Will code for food.
Bompa
Administrator
Lifer
*****
Offline Offline

Posts: 564


Where does this show?


View Profile
« Reply #3 on: April 21, 2007, 04:37:53 AM »

Ah, but perk said "extract", not "validate", so I was thinking what if we wanted to
get an email off of a web page?


 Devilish


but actually, i was just looking for a reason to post.  :rofl:

Bompa


(is it just my connection, or is this forum slow?)

Logged

"The most beautiful and profound emotion we can experience is the sensation of the mystical..." - Albert Einstein
cdc
Expert
****
Offline Offline

Posts: 105


View Profile
« Reply #4 on: April 21, 2007, 04:51:14 AM »

As usual, perk is right. The code will extract all the emails from inputbuff, so if inputbuff is a webpage, you can grab all the emails off it.

My mistake. Sorry for the confusion.
Logged

Will code for food.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #5 on: April 21, 2007, 12:13:04 PM »

Sorry I was not clear - yes, $inputBuff is just a variable I chose -
it sounded better than $webPageIAmHarvestingFrom  ROFLMAO

Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Caligula
Rookie
**
Offline Offline

Posts: 39



View Profile
« Reply #6 on: April 24, 2007, 04:49:49 PM »

Ohhh  I have one of these too!

simple - basic.. heres the whole code...

Code:

<?php


$file 
file_get_contents("http://www.yoursite.com");

if( 
$file )
{
  
preg_match_all'/<a href="mailto\:(.+?)"/'$file$outputPREG_SET_ORDER );
  foreach( 
$output as $item )
  {
    echo 
"$item[1]<br>";
  }
}


?>




Logged
Pages: [1]
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!