I have a multiline log file that I am attempting to parse with a regex and javascript into something more readable, I have used this question as a reference but am getting unexpected results Javascript replace with reference to matched group?.
Basically b logs "first time" undefined "second time" where I would expect to see the file name as the second match.
Here is a sample of the regex and data string that I am trying to match which results in matches. http://regex101.com/r/bW9xD4
I am trying to order the matches so that the filename is first, followed by the first time matched followed by the second time matched, can anyone point me in the right direction?
Code
var VIRTUAL = (function() {
// Module globals
var $ = {};
// Module methods
$ = {
compareDelivery : function( data ) {
var regex = new RegExp( '(\\d{2}:\\d{2}:\\d{2})|([0-9a-z]+.xml)', 'gmi' ), out = [];
var found = data.replace(regex, function ( a, b, c ) {
console.log(a);
});
return out;
}
};
return $;
}());