开发者

getting domain age using preg match all

开发者 https://www.devze.com 2023-02-11 06:46 出处:网络
I would like to calculate the domain age of a website the content is from http://who.godaddy.com/whoisverify.aspx

I would like to calculate the domain age of a website the content is from http://who.godaddy.com/whoisverify.aspx

here are some result that i found from godaddy.

Created on: 26-Dec-03
Record created on 2009-01-15.
Creation date: 27 Oct 2006 19:43:06
Created on..............: 1997-03-28

I would like to get the year and subtract it to the current year t开发者_开发百科o get the domain age. but there are at least 4 creation date format how could i check them all using preg_match_all to get the year domain age?

Please help me guys, Thanks in advance.


Find a line that has 'creat' on it then capture everything from the first digit to the new line character (or .)

Might have to change the (?:\n|\.) though based on the actual text

$str =  <<<END
Created on: 26-Dec-03
Record created on 2009-01-15.
Creation date: 27 Oct 2006 19:43:06
Created on..............: 1997-03-28

END;

preg_match_all( '~creat.*?(\d.*?)(?:\n|\.)~i', $str, $matches );

print_r($matches);


Instead of trying to create on catch-all regex pattern I would look for a line that has creat on it (case insensitive) then search it for a variety of date formats.

0

精彩评论

暂无评论...
验证码 换一张
取 消