$re = '/.*(?\'Event\'eventId=\d+).*(?\'IP\'dst=\d+.\d+.\d+.\d+).*/';
$str = 'Alert event match count [1], threshold [1] sec
Alert base events are:
Event Time [March 17, 2017 4:13:31 PM BRT] Event Receipt Time [March 17, 2017 4:13:32 PM BRT] Event Device Address [10.1.1.53] Event Content [CEF:0|Microsoft|Microsoft Windows||Microsoft-Windows-Security-Auditing:4729|A member was removed from a security-enabled global group.|Low| eventId=1199381 externalId=4729 categorySignificance=/Informational categoryBehavior=/Authorization/Delete categoryDeviceGroup=/Operating System catdt=Operating System categoryOutcome=/Success categoryObject=/Host/Operating System art=1489777997695 cat=Security deviceSeverity=Audit_success rt=1489777995000 sntdom=TCU suser=b2br_igorht_a suid=0x4a92603f dhost=SRV-DCC.tcu.gov.br dst=10.1.0.36 destinationZoneURI=/All Zones/ArcSight System/Private Address Space Zones/RFC1918: 10.0.0.0-10.255.255.255 dntdom=TCU duser=S-1-5-21-2076597496-86852003-636688714-284199 duid=CN\\=B2BR CLAUDIO GERMANO da COSTA PEREIRA,OU\\=B2BR,OU\\=Semop,OU\\=Gerenciamento de Servicos,OU\\=_Gerenciamento,DC\\=tcu,DC\\=gov,DC\\=br dpriv=- cs2=Account Management:Security Group Management cs6=TCU\\\\Library Admins c6a4=fe80:0:0:0:250:56ff:febb:4bc0 cs1Label=Accesses cs2Label=EventlogCategory cs4Label=Reason or Error Code cs5Label=Authentication Package Name cs6Label=Group Domain and Name cn1Label=LogonType cn2Label=CrashOnAuditFail cn3Label=Count c6a4Label=Agent IPv6 Address ahost=clarc0701tcsb.tcu.gov.br agt=10.1.1.53 agentZoneURI=/All Zones/ArcSight System/Private Address Space Zones/RFC1918: 10.0.0.0-10.255.255.255 av=7.3.0.7886.0 atz=America/Sao_Paulo at=windowsfg dvchost=SRV-DCC.tcu.gov.br dvc=10.1.0.36 deviceZoneURI=/All Zones/ArcSight System/Private Address Space Zones/RFC1918: 10.0.0.0-10.255.255.255 deviceNtDomain=TCU dtz=America/Sao_Paulo _cefVer=0.1 ad.WindowsVersion=Windows Server 2008 R2 ad.Group:Security_,ID=S-1-5-21-2076597496-86852003-636688714-269789 ad.WindowsParserFamily=Windows 2008 R2|2008|7|Vista ad.WindowsKeyMapFamily=Windows 2008 R2 ad.EventIndex=1041104459 aid=3AreSLFkBABCACbVBCpi35g\\=\\=]
';
$subst = "${Event}\n${IP}";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
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