This will do the trick. It matches the parts of the $output that you want to keep and puts it in to a variable.
PHP Code:
<?php
$output = "Jan-19-12 03:11:31 [Various_Words] 85.54.177.0 -- invalid HELO: 'PC100521998230'";
$regex = "#^([a-z]{3}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}) .+ (\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3} \-\- invalid HELO: '.+')$#Ui";
preg_match($regex, $output, $match);
if(count($match) == 3)
{
$desired_output = $match[1].' '.$match[2];
var_dump($desired_output);
}
else
{
die('Did not match the correct pattern.');
}
?>
This code outputs:
string(64) "Jan-19-12 03:11:31 85.54.177.0 -- invalid HELO: 'PC100521998230'"
Bookmarks