Re: Another parse problem

From: Date: Wed, 16 Jun 2010 21:04:09 +0000
Subject: Re: Another parse problem
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-306213@lists.php.net to get a copy of this message
On 06/14/2010 08:14 AM, tedd wrote: > Hi gang: > > Considering all the recent parsing, here's another problem to consider > -- given any text, parse the domain-names out of it. > > You may limit the parsing to the most popular TDL's, such as .com, .net, > and .org, but the finished result should be an array containing all the > domain-names found in a text file. > > Cheers, > > tedd Not extensively tested: $domains = array(); if(preg_match_all('/[A-Za-z0-9][-A-Za-z0-9\.]*?\.(com|net|org)/i', $text, $matches)) { $domains = array_unique($matches[0]); } -- Thanks! -Shawn http://www.spidean.com

« previous php.general (#306213) next »