const regex = /([\d\s:,.-]+)\s+\w+\s+\w+QuoteHandler:(\w+)\s+Processed\s+(\d+)\s+quote\s+messages\s+for\s+service\s+([\w\s]+)\s+seq\sno:\s+(\d+)\s+Latency:\s+([-\d\.]+)\s+ms\s+exchange time:\s+([\d+\-\:\.\s]+)msg rate:\s+([\d\.]+)\s+msgs\/sec\s+Packets\s+on\s+client\s+queue:\s+(\d+),\s+packets\s+on\s+client\s+buffer:\s+(\d+),\s+packets\s+on\s+server\s+queue:\s+(\d+),\s+server\s+latency:\s+([\d\.]+)\s+ms,\s+round\s+trip\s+time:\s+([\d\.]+)\s+ms,\s+\w+\s+cnt:\s+(\d+)/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('([\\d\\s:,.-]+)\\s+\\w+\\s+\\w+QuoteHandler:(\\w+)\\s+Processed\\s+(\\d+)\\s+quote\\s+messages\\s+for\\s+service\\s+([\\w\\s]+)\\s+seq\\sno:\\s+(\\d+)\\s+Latency:\\s+([-\\d\\.]+)\\s+ms\\s+exchange time:\\s+([\\d+\\-\\:\\.\\s]+)msg rate:\\s+([\\d\\.]+)\\s+msgs\\\/sec\\s+Packets\\s+on\\s+client\\s+queue:\\s+(\\d+),\\s+packets\\s+on\\s+client\\s+buffer:\\s+(\\d+),\\s+packets\\s+on\\s+server\\s+queue:\\s+(\\d+),\\s+server\\s+latency:\\s+([\\d\\.]+)\\s+ms,\\s+round\\s+trip\\s+time:\\s+([\\d\\.]+)\\s+ms,\\s+\\w+\\s+cnt:\\s+(\\d+)', '')
const str = `04:46:03.318 INFO SprywareDirectFeedQuoteHandler:secondary Processed 136726 quote messages for service NSDQ Direct Feed seq no: 835534 Latency: 1 ms exchange time: 2016-05-17 04:46:03.317 msg rate: 25.157 msgs/sec Packets on client queue: 0, packets on client buffer: 0, packets on server queue: 0, server latency: 0.032 ms, round trip time: 0.103 ms, quote cnt: 136725`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// 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