$re = '/^(\/dev\/(sdf|xvd)[a-p][0-9]{0,1})\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)\%\s+([^\n]*)$/imsU';
$str = '/dev/xvda1 7.8G 1.1G 6.4G 14% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
udev 284M 12K 284M 1% /dev
tmpfs 59M 192K 59M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 295M 0 295M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/xvdf 20G 102M 19G 1% /mnt/data
';
preg_match($re, $str, $matches, PREG_OFFSET_CAPTURE, 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