regex match
| From: | Chris Knipe | Date: | Sat, 19 Apr 2003 16:05:53 +0000 |
| Subject: | regex match | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-144483@lists.php.net to get a copy of this message | ||
Lo all,
I need some quick help with a regex match... Mainly because of the fact that
the output between RH and FreeBSD is different for a command....
My output:
root@netsphere:/# /usr/bin/host -t soa abc.com 192.168.1.1
Using domain server 192.168.1.1:
abc.com start of authority ns01.blah some.email(
2003041901 ;serial (version)
10800 ;refresh period
3600 ;retry refresh this often
604800 ;expiration period
10800 ;minimum TTL
)
the function:
function DigSerial($server,$zone) {
global $config;
$result =
$config->binhost -t soa '$zone' '$server';
if(ereg("try again",$result)) {
return $result;
} else {
preg_match("/.*SOA [^\s\t]+ [^\s\t]+ ([^\s\t]+)/",$result,$serial);
if($serial[1]) {
return $serial[1];
} else {
return 'not available';
}
}
}
Now, on RH, the function will work, seeing that RH's host -t returns the SOA
in one line... FreeBSD however doesn't... Any good regex's around for this?
I only need the serial number... Just the numbers.
--
me