$re = '/^(?<date>\d{4}\-\d{2}\-\d{2}\s+)(?<time>\d{2}\:\d{2}\:\d{2}\s+)(?<sip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s+)(?<csmethod>.+?\s+)(?<csuristem>.+?\s+)(?<csuriquery>.+?\s+)(?<sport>\d{1,3}\s+)(.+?\s+)(?<cip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\s+)(?<csUseragent>.+?\s+)(?<scstatus>\d{1,3}\s+)(?<scsubstatus>\d{1,3}\s+)(?<scwin32status>\d+\s+)(?<scbytes>\d+\s+)(?<csbytes>\d+\s+)(?<timetaken>\d+)?$/';
$str = '2014-05-06 10:27:17 10.200.40.56 GET / - 443 - 10.200.28.7 Mozilla/5.0+(compatible;+MSIE+9.0;+Windows+NT+6.1;+WOW64;+Trident/5.0) 401 2 2148074254 1880 428 109';
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