yep I have tried that but it seem to me that if I want find the word after esc_mon, it can't display myserver.esc
<?php
$str="PROBLEM esc_mon myserver.esc: File System Full: /tmp on esc_mon (Newmon for ESC)";
function string_cut($string,$cut_size)
{
$StringArray=explode(" ",$string);
for($i=0;$i<$cut_size;$i++)
{
$string_cut.=" "."$StringArray[$i]";
}
return "$string_cut";
}
$string="";
$str = string_cut($str,3);
if ((preg_match("/esc_mon/i", $str)) == true)
{
// echo "find the esc_mon match";
if ((preg_match("/.esc:/", $str)) == true)
{
$pattern = "§esc_mon\s(.?)\s§i";
$found = preg_match($pattern,$str,$matches);
if($found > 0) $hostname = $matches[1];
echo "$hostname";
}
else
{
$hostname = "esc_mon";
}
}
else {
$pattern = "§problem\s(.?)\s§i";
$found = preg_match($pattern,$str,$matches);
if ($found > 0) $hostname = $matches[1];
echo "$hostname";
}