const regex = /ERROR\s-[\s]*Method:\s([\w.$]+\([\w.$]*)[,|\)]/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('ERROR\\s-[\\s]*Method:\\s([\\w.$]+\\([\\w.$]*)[,|\\)]', 'g')
const str = `INFO - converting to dex: de.devmil.minimaltext-dex2jar.jar ...
INFO - loading ...
INFO - processing ...
ERROR - Inconsistent code in method: de.devmil.minimaltext.data.battery.BatteryData.equals(java.lang.Object):boolean
ERROR - Inconsistent code in method: de.devmil.minimaltext.billing.IabHelper.queryPurchases(de.devmil.minimaltext.billing.Inventory, java.lang.String):int
ERROR - Inconsistent code in method: de.devmil.minimaltext.weather.WeatherUpdateService.doUpdate(boolean):void
ERROR - 3 errors occurred in following nodes:
ERROR - Method: de.devmil.minimaltext.billing.IabHelper.queryPurchases(de.devmil.minimaltext.billing.Inventory, java.lang.String):int
ERROR - Method: de.devmil.minimaltext.data.battery.BatteryData.equals(java.lang.Object):boolean
ERROR - Method: de.devmil.minimaltext.weather.WeatherUpdateService.doUpdate(boolean):void
ERROR - finished with errors
ERROR - Method: de.devmil.minimaltext.weather.WeatherUpdateService.doUpdate()`;
// 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