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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.