...

View Full Version : Preg_Match_All Question



theflyingminstr
02-19-2010, 07:21 PM
Hi I have a Google Checkout script that automatically logs info into a .log file. I want to make it easier for myself to view any email address' that might be there.

I know the method is preg_match_all after doing some google searching, I'm just not sure of the syntax.

Thanks so much for your help.

JAY6390
02-19-2010, 07:41 PM
Depending on the format of the log, it might be easier to use something like explode rather than a regex for this. can you give the format of the log file?

Otherwise, here's the preg_match_all manual page
http://uk.php.net/manual/en/function.preg-match-all.php
and here's some regexes for email addresses
http://regexlib.com/DisplayPatterns.aspx?cattabindex=0&categoryId=1

theflyingminstr
02-19-2010, 08:06 PM
Hey, thanks for responding.

I'm still throughly confused



<?php

$addr_spec = '([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c'.
'\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|\\x22([^\\x0d'.
'\\x22\\x5c\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x22)'.
'(\\x2e([^\\x00-\\x20\\x22\\x28\\x29\\x2c\\x2e'.
'\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d\\x7f-\\xff]+|'.
'\\x22([^\\x0d\\x22\\x5c\\x80-\\xff]|\\x5c\\x00'.
'-\\x7f)*\\x22))*\\x40([^\\x00-\\x20\\x22\\x28'.
'\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40\\x5b-\\x5d'.
'\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-\\x5d\\x80-\\xff'.
']|\\x5c[\\x00-\\x7f])*\\x5d)(\\x2e([^\\x00-\\x20'.
'\\x22\\x28\\x29\\x2c\\x2e\\x3a-\\x3c\\x3e\\x40'.
'\\x5b-\\x5d\\x7f-\\xff]+|\\x5b([^\\x0d\\x5b-'.
'\\x5d\\x80-\\xff]|\\x5c[\\x00-\\x7f])*\\x5d))*';

$email = "real@email.com - notavalid.email";

$output = preg_match_all("!^$addr_spec$!", $email);

echo $output;

?>



I'm getting some wild expression errors on this one.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum