Jump to content

Regex help...


kickassamd

Recommended Posts

Been trying to extract the kilobytes sent number from this string...

 

Server Statistics for \\testbox Statistics since 5/2/2008 4:06 PM Sessions accepted 1 Sessions timed-out 0 Sessions errored-out 0 Kilobytes sent 16 Kilobytes received 17 Mean response time (msec) 0 System errors 0 Permission violations 0 Password violations 0 Files accessed 16 Communication devices accessed 0 Print jobs spooled 0 Times buffers exhausted Big buffers 0 Request buffers 0 The command completed successfully.

 

ive tried

 

Kilobytes sent [0-9]

Kilobytes sent \d+

Kilobytes sent \d

 

And i get no matches...

preg_match('{Kilobytes sent \d+}', $this->_netStats, $matches);

 

Any help is very appreciated!

Link to comment
https://forums.phpfreaks.com/topic/103966-regex-help/
Share on other sites

try

<?php
$a = 'Server Statistics for \\testbox Statistics since 5/2/2008 4:06 PM Sessions accepted 1 Sessions timed-out 0 Sessions errored-out 0 Kilobytes sent 16 Kilobytes received 17 Mean response time (msec) 0 System errors 0 Permission violations 0 Password violations 0 Files accessed 16 Communication devices accessed 0 Print jobs spooled 0 Times buffers exhausted Big buffers 0 Request buffers 0 The command completed successfully.';
preg_match('/Kilobytes sent\s+(\d+) Kilobytes received\s+(\d+)/', $a, $b);
print_r($b);
?>

Link to comment
https://forums.phpfreaks.com/topic/103966-regex-help/#findComment-532257
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.