adamjblakey Posted April 2, 2008 Share Posted April 2, 2008 I am having a problem with the following, as it is not bringing back any results. <?php $email_match_regex = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$^"; for($i=1;$i<7;$i++) { $content = file_get_contents('http://www.web.co.uk/details.asp?ID='.$i); preg_match_all($email_match_regex, $content, $matches); foreach($matches[1] as $index => $value) { print $index[1]; } } ?> There is one email per id and they like this: <a href="mailto:adam@email.com?Subject=This is the sbject of the email (Company-Name)&Body=Referral from www.web.co.uk%0D%0A%0D%0A" title="Send e-mail to company name"> Cheers, Adam Quote Link to comment Share on other sites More sharing options...
effigy Posted April 2, 2008 Share Posted April 2, 2008 The dollar requires the email to be at the end of the string; also, I wouldn't use a metacharacter for the delimiter: /([-\w]+)(\.[-\w]+)*@([-a-z\d]+)(\.[-a-z\d]+)*(\.[a-z]{2,4})/i Quote Link to comment Share on other sites More sharing options...
adamjblakey Posted April 2, 2008 Author Share Posted April 2, 2008 Thank you for your reply, I have now done this: <?php $email_match_regex = "/([-\w]+)(\.[-\w]+)*@([-a-z\d]+)(\.[-a-z\d]+)*(\.[a-z]{2,4})/i"; for($i=1;$i<7;$i++) { $content = file_get_contents('http://www.uk-disco.co.uk/org-details.asp?OrgID='.$i); preg_match_all($email_match_regex, $content, $matches); foreach($matches[1] as $index => $value) { print $index[1]; } } ?> But this returns no results, any ideas? Quote Link to comment Share on other sites More sharing options...
effigy Posted April 2, 2008 Share Posted April 2, 2008 Loading that page redirects to http://www.uk-disco.co.uk/org-notfound.asp for me. Quote Link to comment Share on other sites More sharing options...
adamjblakey Posted April 2, 2008 Author Share Posted April 2, 2008 Sorry about that i did not check the id's i have tried setup this which i know has data but it does not work still: <?php $email_match_regex = "/([-\w]+)(\.[-\w]+)*@([-a-z\d]+)(\.[-a-z\d]+)*(\.[a-z]{2,4})/i"; $content = file_get_contents('http://www.uk-disco.co.uk/org-details.asp?OrgID=792'); preg_match_all($email_match_regex, $content, $matches); foreach($matches[1] as $index => $value) { print $index[1]; } ?> Cheers, Adam Quote Link to comment Share on other sites More sharing options...
effigy Posted April 2, 2008 Share Posted April 2, 2008 The source is using the decimal entity of 64, rather than the character "@": <pre> <?php $email_match_regex = "/([-\w]+)(\.[-\w]+)*(?:@|@)([-a-z\d]+)(\.[-a-z\d]+)*(\.[a-z]{2,4})/i"; $content = file_get_contents('http://www.uk-disco.co.uk/org-details.asp?OrgID=792'); preg_match_all($email_match_regex, $content, $matches); print_r($matches); ?> </pre> Quote Link to comment Share on other sites More sharing options...
adamjblakey Posted April 2, 2008 Author Share Posted April 2, 2008 Thank you very much for that, just one last thing, how would i go about just the email address? I tried <?php $email_match_regex = "/([-\w]+)(\.[-\w]+)*(?:@|@)([-a-z\d]+)(\.[-a-z\d]+)*(\.[a-z]{2,4})/i"; $content = file_get_contents('http://www.uk-disco.co.uk/org-details.asp?OrgID=792'); preg_match_all($email_match_regex, $content, $matches); print $matches[0]; ?> but did not seem to work. Quote Link to comment Share on other sites More sharing options...
effigy Posted April 2, 2008 Share Posted April 2, 2008 print_r shows the layout of the array: $matches[0][0]; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.