how to parse this string with java script
19 51 2.108997
20 47 2.1089
like this
<span>19 51</span> <span>2.108997</span>
<span>20 47</span> <span>2.1089</span>
Assuming you're using jQuery..
var input = '19 51 2.108997\n20 47 2.1089';
var lines = input.split('\n');
var output = '';
$.each(lines, function(key, line) {
var parts = line.split(' ');
output += '<span>' + parts[0] + ' ' + parts[1] + '</span><span>' + parts[2] + '</span>\n';
});
$(output).appendTo('body');
lines variable will be a zero-based array after the second line, so you can access individual elements that were matched (each newline in the above example) in the following manner: lines[0], lines[1] and so on.
<span>19 51</span> <span>...</span>and<span>20 47</span> <span>...</span>??