I am using a code that pulls a data between two strings.
Below is my code works fine but i got a problem with it:
function pullAllDataBetween(file_data, str1, str2) {
var string_nodes = [];
var append = false;
for (var i = 0; i < file_data.length; i++) {
if (file_data[i] === str1) {
append = true;
continue;
} else if (file_data[i] === str2) {
append = false;
break;
}
if (append) {
string_nodes.push(file_data[i]);
}
}
return string_nodes;
}
Then use it with this
const data = file_data.split("\r\n");
const string_nodes = pullAllDataBetween(data, "BEGINNING", "ENDING" );
It successfully pulls out the data from this kind of format:
1 BEGINNING
2 1 1 0 0; 2 4 0 0; 3 7 0 0; 4 0 0 -1; 5 1 0 -1; 6 1 0.75 -1; 7 4 0 -1;
3 8 4 0.75 -1; 9 7 0 -1; 10 7 0.75 -1; 11 8 0 -1; 12 0 0 -4; 13 1 0 -4;
4 14 1 0.75 -4; 15 4 3 -4; 16 7 0 -4; 17 7 0.75 -4; 18 8 0 -4; 19 0 0 -7;
5 ENDING
Result
['1 1 0 0; 2 4 0 0; 3 7 0 0; 4 0 0 -1; 5 1 0 -1; 6 1 0.75 -1; 7 4 0 -1;',
'8 4 0.75 -1; 9 7 0 -1; 10 7 0.75 -1; 11 8 0 -1; 12 0 0 -4; 13 1 0 -4;',
'14 1 0.75 -4; 15 4 3 -4; 16 7 0 -4; 17 7 0.75 -4; 18 8 0 -4; 19 0 0 -7;']
Then i have this kind of format :
1 START JOB INFORMATION
2 DATE 23-May-18
3 END JOB INFORMATION
4 INPUT WIDTH 79
5 UNIT METER KN
6 BEGINNING
7 5 13 16 22 24 ENDING
8 ISOTROPIC STEELAPPROX
9 E 2e+008
10 POISSON 0.27
11 DENSITY 77.01
12 ALPHA 1.2e-005
now i cant make use of my code. I got stuck.
i am trying to get a result like the one below:
['5; 13; 16; 22; 24;']
thanks for those who will help.