I am new to regex. I have been stuck with this and couldn't find a way to figure this out.
I am using a nodejs in back-end. There is an output to clear things up with regex,
results: ["Comparing /path/uploads/vector-1474379968511.data with /path/x1.data."," + Squared l2 distance between representations: 2.067",
"Comparing /path/uploads/vector-1474379968511.data with /path/x2.data."," + Squared l2 distance between representations: 1.670",
"Comparing /path/uploads/vector-1474379968511.data with /path/x3.data."," + Squared l2 distance between representations: 1.686",
"Comparing /path/uploads/vector-1474379968511.data with /path/x4.data."," + Squared l2 distance between representations: 0.287"]
var input = ["Comparing /path/uploads/vector-1474379968511.data with /path/x1.data.", " + Squared l2 distance between representations: 2.067",
"Comparing /path/uploads/vector-1474379968511.data with /path/x2.data.", " + Squared l2 distance between representations: 1.670",
"Comparing /path/uploads/vector-1474379968511.data with /path/x3.data.", " + Squared l2 distance between representations: 1.686",
"Comparing /path/uploads/vector-1474379968511.data with /path/x4.data.", " + Squared l2 distance between representations: 0.287"];
var output = {};
var findPath = / with (.*)\.$/, findValue = /(\d+\.\d+)$/;
var path, value;
for (var i = 0, l = input.length; i < l; i++) {
path = input[i].match(findPath)[1];
i++; // move to next item
value = input[i].match(findValue)[1];
output[path] = value; // store however you like
}
console.log(output);