I am trying to create 3 PHP regular expressions which do three things..
- Gets emails e.g mr.jones@apple-land.com
- Gets dates e.g 31/05/90 or 31-Jun-90
- Gets nameservers e.g ns1.apple.co.uk
I have a big chunk of text and want to extract these things from it.
What I have so far is:
$regexp = '/[A-Za-z0-9\.]+[@]{1}[A-Za-z0-9\.]+[A-Za-z]{2,4}/i';
preg_match_all($regexp, $output, $email);
$regexp = '/[A-Za-z0-9\.]+[^@]{1}/i';
preg_match_all($regexp, $output, $nameservers);
$regexp = '/[0-9]{2,4}[-\/]{1}([A-Za-z]{3}|[0-9]{2})[-\/]{1}[0-9]{2,4}/i';
preg_match_all($regexp, $output, $dates);
Dates and emails work, but i dont know if that is an efficient way to do it..
Nameservers just dont work at all.. essentially I want to find any combinations of letters and numbers which have dots in between but not @ symbols..
Any help would be greatly appreciated.
Thanks