as part of a larger application we have a bit of code that processes whois to determine domain name expiry dates. Most formats are easily parsed, but Register.Com has thrown the little regex for a loop and I am unsure as to a clean workaround.
Here is what we have; ... $pregmatchstring="/([\s])*(Renewal\DDate|Registered\sthrough|Expires|Record\sExp ires|Domain\sExpires|Expiry\sDate)([\D\s]*)(.*)/i"; ... exec($command,$cresult,$cstatus); # puts all lines into array $expire=''; for($i=0;$i<count($cresult);$i++){ if(preg_match($pregmatchstring,$cresult[$i], $matches)){ $expire.=strtotime(trim($matches[4],". \t\n\r")); }else{ $expire.=''; } } ... This regex handles pretty much everything... / > strip space characters from the front (some indent) ([\s])* > identify the exipery date line from other verbose entries containing "expir" or similar (Renewal\DDate|Registered\sthrough|Expires|Record\sExpires|Domain\sExpires|Expir y\sDate) > any other spaces, .....:, or other verbose crap afterwards **except for numbers** > essentially grabs everything else up to the first number > thought I was being slick with this one ([\D\s]*) > grab numbers/date - gets the 2002/12/01, 09-APR-03, 2002-08-19 00:00:00.000 (.*) > and make case insensitive /i takes care of Renewal-Date: 2002/12/01 Registered through- 08/16/02 00:00:00 Expires on: 09-APR-03 expires: 2003-01-17 02:16:03 Domain expires on 03-Apr-2003 Record expires on 2002-08-19 00:00:00.000 Record expires on 29-Mar-2003. Record expires on 2003-03-25. DOMAIN EXPIRES : 2003-03-25. Expiry Date..........2003.03.25 HOWEVER... this simple solution breaks for register.com because of their date format Expires on..............: Tue, Jul 29, 2003 because the regex only returns "29, 2003" as the date which barfs for the strtotime() not the regex fault of the strtotime fault, as they are doing what instructed... Any ideas on a way to simply overcome the register.com format and still keep a simple all inclusive regex for all registrars? Thanks Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php