Re: regex match
| From: | Jason k Larson | Date: | Sat, 19 Apr 2003 18:41:50 +0000 |
| Subject: | Re: regex match | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-144492@lists.php.net to get a copy of this message | ||
If all you need is the serial, and it's the only 10 digit number ...
I changed it to this and it worked for me, on Linux (redhat).
preg_match('/([0-9]{10})/',$result,$serial);
I didn't have a FreeBSD box to test it on, but I'm pretty sure this would still work, due to the serial being the only 10 digit number.
HTH,
der Ritter
aka: Jason k Larson
Chris Knipe wrote:
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