const regex = /(?s)(?:.*(?:datetime:)(?<datetime>.*?)(?:$|\s*\|))?(?:.*(?:hostname:)(?<hostname>.*?)(?:$|\s*\|))?(?:.*(?:threadId:)(?<threadId>.*?)(?:$|\s*\|))?(?:.*(?:userId:)(?<userId>.*?)(?:$|\s*\|))?(?:.*(?:correlationId:)(?<correlationId>.*?)(?:$|\s*\|))?(?:.*(?:applicationName:)(?<applicationName>.*?)(?:$|\s*\|))?(?:.*(?:direction:)(?<direction>.*?)(?:$|\s*\|))?(?:.*(?:operationName:)(?<operationName>.*?)(?:$|\s*\|))?(?:.*(?:className:)(?<className>.*?)(?:$|\s*\|))?(?:.*(?:methodName:)(?<methodName>.*?)(?:$|\s*\|))?(?:.*(?:latency:)(?<latency>.*?)(?:$|\s*\|))?(?:.*(?:clusterName:)(?<clusterName>.*?)(?:$|\s*\|))?(?:.*(?:webServiceType:)(?<webServiceType>.*?)(?:$|\s*\|))?(?:.*(?:strCode:)(?<strCode>.*?)(?:$|\s*\|))?(?:.*(?:strDescription:)(?<strDescription>.*?)(?:$|\s*\|))?(?:.*(?:payload:)(?<payload>.*?)(?:$|\s*\|))?(?:.*(?:requestVerb:)(?<requestVerb>.*?)(?:$|\s*\|))?(?:.*(?:httpStatusCode:)(?<httpStatusCode>.*?)(?:$|\s*\|))?(?:.*(?:httpHeaders:)(?<httpHeaders>.*?)(?:$|\s*\|))?(?:.*(?:requestUrl:)(?<requestUrl>.*?)(?:$|\s*\|))?(?:.*(?:code:)(?<code>.*?)(?:$|\s*\|))?(?:.*(?:strSystemName:)(?<strSystemName>.*?)(?:$|\s*\|))?(?:.*(?:description:)(?<description>.*?)(?:$|\s*\|))?(?:.*(?:content\-length:)(?<content_length>.*?)(?:\s*\|))?(?:.*(?:logMessage:)(?<logMessage>.*?)(?:$|\s*\|))?
/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?s)(?:.*(?:datetime:)(?<datetime>.*?)(?:$|\\s*\\|))?(?:.*(?:hostname:)(?<hostname>.*?)(?:$|\\s*\\|))?(?:.*(?:threadId:)(?<threadId>.*?)(?:$|\\s*\\|))?(?:.*(?:userId:)(?<userId>.*?)(?:$|\\s*\\|))?(?:.*(?:correlationId:)(?<correlationId>.*?)(?:$|\\s*\\|))?(?:.*(?:applicationName:)(?<applicationName>.*?)(?:$|\\s*\\|))?(?:.*(?:direction:)(?<direction>.*?)(?:$|\\s*\\|))?(?:.*(?:operationName:)(?<operationName>.*?)(?:$|\\s*\\|))?(?:.*(?:className:)(?<className>.*?)(?:$|\\s*\\|))?(?:.*(?:methodName:)(?<methodName>.*?)(?:$|\\s*\\|))?(?:.*(?:latency:)(?<latency>.*?)(?:$|\\s*\\|))?(?:.*(?:clusterName:)(?<clusterName>.*?)(?:$|\\s*\\|))?(?:.*(?:webServiceType:)(?<webServiceType>.*?)(?:$|\\s*\\|))?(?:.*(?:strCode:)(?<strCode>.*?)(?:$|\\s*\\|))?(?:.*(?:strDescription:)(?<strDescription>.*?)(?:$|\\s*\\|))?(?:.*(?:payload:)(?<payload>.*?)(?:$|\\s*\\|))?(?:.*(?:requestVerb:)(?<requestVerb>.*?)(?:$|\\s*\\|))?(?:.*(?:httpStatusCode:)(?<httpStatusCode>.*?)(?:$|\\s*\\|))?(?:.*(?:httpHeaders:)(?<httpHeaders>.*?)(?:$|\\s*\\|))?(?:.*(?:requestUrl:)(?<requestUrl>.*?)(?:$|\\s*\\|))?(?:.*(?:code:)(?<code>.*?)(?:$|\\s*\\|))?(?:.*(?:strSystemName:)(?<strSystemName>.*?)(?:$|\\s*\\|))?(?:.*(?:description:)(?<description>.*?)(?:$|\\s*\\|))?(?:.*(?:content\\-length:)(?<content_length>.*?)(?:\\s*\\|))?(?:.*(?:logMessage:)(?<logMessage>.*?)(?:$|\\s*\\|))?
', 'gm')
const str = `[INFO] 28 Jun 2018 14:02:29,480 SYSLOG->|datetime:20180628140229479+0000|hostname:marketingprofile-deployment-877c7f857-cv9d6/10.44.0.15(10.44.0.15)|threadId:47-http-nio-11551-exec-1(main)|userId:null|correlationId:c7943b58-a584-4cba-ad44-45cf1af3a400|applicationName:RETRIEVEMARKETINGPROFILE-V1|direction:ENTERING|operationName:RetrievalService|className:LogServletFilter|methodName:logRequest|clusterName:TXH|webServiceType:REST|payload:<?xml version="1.0" encoding="UTF-8" standalone="no"?><!--<INPUTINFO> <BBCAN>8881008923</BBCAN> </INPUTINFO>--><INPUTINFO> <APPLICATIONID>NCOG</APPLICATIONID> <CLINETREQUESTID>test</CLINETREQUESTID> <VISION> <CUSTOMERID>151862438</CUSTOMERID> <ACCOUNTID>0001</ACCOUNTID> </VISION> <!--<VOICECAN>0178430862672</VOICECAN>--> <!-- <BBCAN>060002792607</BBCAN> --> <!--<BTN>2016221232</BTN> --> <!-- <ADDRESS> <ADDRESSID>030862772</ADDRESSID> <STATE>MD</STATE> </ADDRESS> --> <!--<SSPBAN>0178430862772</SSPBAN>--> <!--<PCAN>E100007652</PCAN> --> </INPUTINFO>|requestVerb:POST|httpHeaders:content-length={534};ssp-correlationid={c7943b58-a584-4cba-ad44-45cf1af3a400};host={10.44.0.15:11551};content-type={text/xml};connection={Keep-Alive};accept-encoding={gzip};user-agent={Apache-HttpClient/4.1.1 (java 1.5)};|requestUrl:http://10.44.0.15:11551/retrieveMarketingProfile/RetrievalService?null
Security framework of XStream not initialized, XStream is probably vulnerable.
[INFO] 28 Jun 2018 14:02:29,592 SYSLOG->|datetime:20180628140229591+0000|hostname:marketingprofile-deployment-877c7f857-cv9d6/10.44.0.15(10.44.0.15)|threadId:47-http-nio-11551-exec-1(main)|userId:null|correlationId:c7943b58-a584-4cba-ad44-45cf1af3a400|applicationName:RETRIEVEMARKETINGPROFILE-V1|direction:ENTERING|className:com.verizon.ssp.gateway.adapter.WebServiceAdaptor|clusterName:TXH|webServiceType:REST|payload:<!--<INPUTINFO>
<BBCAN>8881008923</BBCAN>
</INPUTINFO>-->
<INPUTINFO>
<APPLICATIONID>NCOG</APPLICATIONID>
<CLINETREQUESTID>test</CLINETREQUESTID>
<VISION>
<CUSTOMERID>151862438</CUSTOMERID>
<ACCOUNTID>0001</ACCOUNTID>
</VISION>
<!--<VOICECAN>0178430862672</VOICECAN>-->
<!-- <BBCAN>060002792607</BBCAN> -->
<!--<BTN>2016221232</BTN> -->
<!-- <ADDRESS>
<ADDRESSID>030862772</ADDRESSID>
<STATE>MD</STATE>
</ADDRESS> -->
<!--<SSPBAN>0178430862772</SSPBAN>-->
<!--<PCAN>E100007652</PCAN> -->
</INPUTINFO>|content-length:534|logMessage:<!--<INPUTINFO>
<BBCAN>8881008923</BBCAN>
</INPUTINFO>-->
<INPUTINFO>
<APPLICATIONID>NCOG</APPLICATIONID>
<CLINETREQUESTID>test</CLINETREQUESTID>
<VISION>
<CUSTOMERID>151862438</CUSTOMERID>
<ACCOUNTID>0001</ACCOUNTID>
</VISION>
<!--<VOICECAN>0178430862672</VOICECAN>-->
<!-- <BBCAN>060002792607</BBCAN> -->
<!--<BTN>2016221232</BTN> -->
<!-- <ADDRESS>
<ADDRESSID>030862772</ADDRESSID>
<STATE>MD</STATE>
</ADDRESS> -->
<!--<SSPBAN>0178430862772</SSPBAN>-->
<!--<PCAN>E100007652</PCAN> -->
</INPUTINFO>
[ERROR] 28 Jun 2018 14:02:29,687 BaseDao : Consistency Level : ONE for Key Space: grid_mktprofile
[INFO]threadId:47-http-nio-11551-exec-1(main)|userId:null|correlationId:c7943b58-a584-4cba-ad44-45cf1af3a400|
[INFO]threadId:47-http-nio-11551-exec-1(main)|userId:null|correlationId:c7943b58-a584-4cba-ad44-45cf1af3a400|
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions