const regex = /^.*\((\d*),(\d*)\)\s*:\s*(.*)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^.*\\((\\d*),(\\d*)\\)\\s*:\\s*(.*)', 'gm')
const str = `C:\\Users\\User\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\Experts\\TradeControl.mq5 : information: Checking 'TradeControl.mq5'
C:\\Users\\User\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\Experts\\TradeControl.mq5(25,5) : error 256: 'abc' - undeclared identifier
C:\\Users\\User\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\Experts\\TradeControl.mq5(27,4) : error 152: 'OrdersPrev' - some operator expected
C:\\Users\\User\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\Experts\\TradeControl.mq5(88,16) : warning 43: possible loss of data due to type conversion
C:\\Users\\User\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\Experts\\TradeControl.mq5(96,22) : warning 43: possible loss of data due to type conversion
C:\\Users\\User\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\Experts\\TradeControl.mq5(147,22) : warning 43: possible loss of data due to type conversion
C:\\Users\\User\\AppData\\Roaming\\MetaQuotes\\Terminal\\D0E8209F77C8CF37AD8BF550E51FF075\\MQL5\\Experts\\TradeControl.mq5(202,22) : warning 43: possible loss of data due to type conversion
: information: Result 2 error(s), 4 warning(s)
[Finished in 2.7s]`;
// 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