The code below gives a final undefined part...trying to figure where the undefined part is created. Any thoughts?
jQuery(document).ready(function() {
console.log("ok");
var object = {};
var text = `#DATA1 1000
#DATA2 1000
#DATA3 2000
#DIM 1 "test"
#DIM 6 "test2"`;
var lines = text.split('\n');
for (var line = 0; line < lines.length; line++) {
//console.log(lines[line]);
if (lines[line].startsWith("#DIM")) {
//console.log(lines[line]);
var myRegexp = /[^\s"]+|"([^"]*)"/gi;
var row = [];
do {
//Each call to exec returns the next regex match as an array
var match = myRegexp.exec(lines[line]);
if (match != null) {
//console.log(match);
row.push(match[1] ? match[1] : match[0]);
object[row[1]] = {
namn: row[2]
};
}
//console.log(row);
} while (match != null);
}
}
console.log(object);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
rowhas only one element in it (row[0]), sorow[1]androw[2]are bothundefined. But what is the end goal of this code?