$re = '/\[((?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))\]/';
$str = 'Nov 16 14:21:05 192.168.77.20/192.168.77.167 1 2016-11-16T14:21:05+08:00 s_sys@aaa1 snmptrapd 19644 - - \'14:21:5 16/11/2016 UDP: [10.80.0.254]:58919 wcore Cold Start sysUpTimeInstance = 24:16:28:17.07 snmpTrapOID.0 = cmnMacMoveNotification cmnMACMoveAddress.0 = e0:66:78:8a:93:bb cmnMACMoveVlanNumber.0 = 30 cmnMACMoveFromPortId.0 = 1669 cmnMACMoveToPortId.0 = 1668 cmnMACMoveTime.0 = 24:16:28:17.07\'';
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