const regex = /(\(loggingInfo\)|\(beneLoggingInfo\)) - (?<vendorinfo>[^|]*)\|(?<login>[^|]*)\|(?<action>[^|]*)\|(?<timeStamp>[^\|]*)\|(?<tag2>[^\|]*)\|(?<tag6>[^\|]*)\|(?<tag7>[^\|]*)\|(?<tag8>[^\|]*)\|(?<tag9>[^\|]*)\|(?<tag10>[^\|]*)\|(?<tag11>[^\|]*)\|/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(\\(loggingInfo\\)|\\(beneLoggingInfo\\)) - (?<vendorinfo>[^|]*)\\|(?<login>[^|]*)\\|(?<action>[^|]*)\\|(?<timeStamp>[^\\|]*)\\|(?<tag2>[^\\|]*)\\|(?<tag6>[^\\|]*)\\|(?<tag7>[^\\|]*)\\|(?<tag8>[^\\|]*)\\|(?<tag9>[^\\|]*)\\|(?<tag10>[^\\|]*)\\|(?<tag11>[^\\|]*)\\|', 'gm')
const str = `18 Jul 2018 09:05:31,068 INFO (loggingInfo) - Auto CRM|ppope|ApplicationLogin|Wed Jul 18 09:05:31 CDT 2018|CSR agent successfully logged in||Successful||||NA|
22 Oct 2018 08:36:41,164 INFO (beneLoggingInfo) - Beneficiary Administration|TESTWHBENE|APPLICATION LOGIN|Mon Oct 22 08:36:41 CDT 2018|User successfully logged in for Client = 070||SUCCESSFUL||||NA|
22 Oct 2018 00:43:23,845 INFO (loggingInfo) - Inquiry Application|TUSER4444|APPLICATION LOGIN|Mon Oct 22 00:43:23 CDT 2018|User successfully logged in for Client : 580||SUCCESSFUL||||NA|
01 Oct 2018 09:29:33,508 INFO (loggingInfo) - ISIS PersonalPlan|TESTOMAR|APPLICATION LOGIN|Mon Oct 01 09:29:33 CDT 2018|User successfully logged in for Client : 002||SUCCESSFUL||||NA|
24 Oct 2018 13:46:07,647 INFO (loggingInfo) - Web-Billing|egunderson| User Authentication|10/24/2018 01:46:07 PM| User Authentication|NA|True| NA| NA| NA| NA|
`;
// 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