$re = '/{(?<Time>\d{2}:\d{2}:\d{2})\} System:"(?<SystemName>[^"]+)" StarPos:\((?<StarPos_X>[^,]+),(?<StarPos_Y>[^,]+),(?<StarPos_Z>[^)]+)\)ly( Body:(?<Body>\d+) RelPos:\((?<RelPos>[^)]+)\)km)?(\s+(?<TravelMode>\w+))?/';
$str = '// Verbose Netlog
{09:41:22} System:"Iorant ND-K d8-1" StarPos:(-1085.656,-20.906,64947.563)ly Body:0 RelPos:(-4.31614e+08,1.01307e+07,3.68466e+07)km NormalFlight
// Non-verbose netlog
{21:14:06} System:"Myeia Thaa WD-K d8-0" StarPos:(-1655.375,-22.625,64936.594)ly NormalFlight
// Entries with weird characters
{21:14:06} System:"Sagittarius A*" StarPos:(0.375,30.625,32000.594)ly NormalFlight
{21:14:06} System:"Foo Bar 123 !£$%*[]{}-=_+*" StarPos:(0.375,30.625,32000.594)ly NormalFlight';
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