系统消息可能包含以下状态句子:
此功能执行 312 次,最常用于 Urbanus : 16.06.2012 14:10 。
句子总是在一行。
我需要:
我尝试了以下操作,但它无法正常工作:
$matches = preg_replace(
"/This function was executed ([1-9]|[1-9][0-9]|[1-9][0-9][0-9]) times, most often used by process (.+?): ((Today|Yesterday|[0-9]{2}.[0-9]{2}.[0-9]{4}) ([0-9]{2}:[0-9]{2}))./iU",
"",
$message);
答案 0 :(得分:1)
1part:
尝试使用preg_match_all
。我也改进你的模式
$message = 'This function was executed 312 times, most often used by process Urbanus: 16.06.2012 14:10.';
$matches = array();
if (preg_match_all("/This function was executed ([1-9]|[1-9][0-9]+) times, most often used by process (\w+?): ((Today|Yesterday|[0-9]{2}.[0-9]{2}.[0-9]{4}) ([0-9]{2}:[0-9]{2}))./i", $message, $matches)) {
var_dump($matches);
}