Hey guys.
I am trying to match the FDSize: in the following:
Gid: 48 48 48 48 FDSize: 64 Groups: 48 425 VmPeak: 289928 kB
It comes from /proc/status
is not fixied length, and neither is the lines above or below.
Can any one help?
Thanks
Hey guys.
I am trying to match the FDSize: in the following:
Gid: 48 48 48 48 FDSize: 64 Groups: 48 425 VmPeak: 289928 kB
It comes from /proc/status
is not fixied length, and neither is the lines above or below.
Can any one help?
Thanks
But the term 'FDSize: ' always has the same length. So you just get the position at the end of that substring and the position of the following space. Everything in between will be the number I assume you wish to extract. No regular expression needed. strpos
and substr
should suffice.
Try something like this:
preg_match_all('`FDSize: (\\d+)`s', $subject, $matches);
print_r($matches);
Not really sure why/how/when you have to do this. I should've asked questions before posting an answer but i didn't. Here are some ways to get that out of a line though...
$line = 'Gid: 48 48 48 48 FDSize: 64 Groups: 48 425 VmPeak: 289928 kB';
// in a loop...
echo current( explode(' ', end( explode( 'FDSize: ', $line ) ) ) );
// or
preg_match_all('~fdsize: (\d+)~i', $line, $matches);
$mystr='Gid: 48 48 48 48 FDSize: 64 Groups: 48 425 VmPeak: 289928 kB';
$str = explode(":",$mystr);
foreach($str as $k=>$word){
if(strpos($word,"FDSize") !== FALSE){
print $str[$k+1];
}
}