perkiset

^[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.

Bompa

Hi Perk,

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


Bompa

cdc

$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

Bompa

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


Applause


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

Bompa


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

cdc

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.

perkiset

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

Caligula

Ohhh  I have one of these too!

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



<?

php

 


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

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


?>




Perkiset's Place Home   Politics @ Perkiset's