$re = '/^cache\s(\d+)/m';
$str = 'cache 5764452352
rss 2929250304
rss_huge 0
mapped_file 283906048
pgpgin 19709097
pgpgout 17586611
pgfault 39612525
pgmajfault 3757
inactive_anon 160579584
active_anon 3931484160
inactive_file 3560427520
active_file 1040818176
unevictable 49152
hierarchical_memory_limit 9223372036854775807
total_cache 5764452352
total_rss 2929250304
total_rss_huge 0
total_mapped_file 283906048
total_pgpgin 19709097
total_pgpgout 17586611
total_pgfault 39612525
total_pgmajfault 3757
total_inactive_anon 160579584
total_active_anon 3931484160
total_inactive_file 3560427520
total_active_file 1040818176
total_unevictable 49152';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result
var_dump($matches);
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for PHP, please visit: http://php.net/manual/en/ref.pcre.php