I have a text document that lists urls with their subject and an email address. I need to extract all urls with their subject and the email address and put this all into a csv file. I just need to know how I can use regex to do this. Currently I am able to extract all urls but I need the email and subject associated with them. This is what I am working with so far:
$file=file_get_contents('/data/urls.txt');
$pattern='([A-Za-z][A-Za-z0-9+.-]{1,120}:[A-Za-z0-9/](([A-Za-z0-9$_.+!*,;/?:@&~=-])|% [A-Fa-f0-9]{2}){1,333}(#([a-zA-Z0-9][a-zA-Z0-9$_.+!*,;/?:@&~=%-]{0,1000}))?)';
preg_match_all($pattern, $file, $matches);
$matches=array_unique($matches[0]);
print_r($matches);
File structure:
Subject: URL
Email: [email protected]
Source URL: http://www.google.com