JSFiddle - React, Tailwind, and code Playground

HTML

<div class="score"><div class="stff_St_1" id="P1">STAVE 1 /7
 [ sy 67; miny 29; maxy 98; minx 71; maxx 772;
   sname "St 1"; pagen 1; sbarn 1;
<div class="bracket"><div class="join">
   join=Y;</div> bracket=Y;</div> brackdown=Y; bthru=Y;

 nobj 8;
<div class="obj x20 typ=ltext fstr=Part` 1 ffnt=1">Object 1 [ x 20; y 57; gaset $8; typ=ltext; fstr "Part` 1"; ffnt 1;]</div>
<div class="obj x92 sy3 typ=clef clef=G cxpose=0">Object 2 [ x 92; y 67; sy 3; typ=clef; clef G; cxpose 0;]</div>
<div class="obj x116 typ=ts top=4 bot=4">Object 3 [ x 116; y 67; typ=ts; top 4; bot 4;]</div>
<div class="obj x146 sy26 typ=note p1 s1 d1/4">Object 4 [ x 146; y 63; sy 26; typ=note; p 1; s 1; d 1/4;]</div>
<div class="obj x306 sy26 typ=note p1 s1 d1/4">Object 5 [ x 306; y 63; sy 26; typ=note; p 1; s 1; d 1/4;]</div>
<div class="obj x462 sy26 typ=note p1 s1 d1/4">Object 6 [ x 462; y 63; sy 26; typ=note; p 1; s 1; d 1/4;]</div>
<div class="obj x618 sy26 typ=note p1 s1 d1/4">Object 7 [ x 618; y 63; sy 26; typ=note; p 1; s 1; d 1/4;]</div>
<div class="obj x771 sy39 typ=barl bn=2">Object 8 [ x 771; y 67; sy 39; typ=barl; bn 2;]</div>
 ]
</div>
<div class="stff_St_2" id="P2">STAVE 2 /7
 [ sy 144; miny 106; maxy 169; minx 71; maxx 772;
   sname "St 2"; pagen 1; sbarn 1;
<div class="bracket"><div class="join">
   join=Y;</div> bracket=Y;</div> brackdown=Y; bthru=Y;

 nobj 4;
<div class="obj x21 typ=ltext fstr=Part` 2 ffnt=1">Object 1 [ x 21; y 130; gaset $8; typ=ltext; fstr "Part` 2"; ffnt 1;]</div>
<div class="obj x92 sy2 typ=clef clef=F cxpose=0">Object 2 [ x 92; y 144; sy 2; typ=clef; clef F; cxpose 0;]</div>
<div class="obj x119 typ=ts top=4 bot=4">Object 3 [ x 119; y 144; typ=ts; top 4; bot 4;]</div>
<div class="obj x146 sy156 typ=note p-1 s2 d1">Object 4 [ x 146; y 148; sy 156; typ=note; p -1; s 2; d 1;]</div>
 ]
</div>
<div class="stff_Timpani" id="P3">STAVE 3 /7
 [ sy 221; miny 183; maxy 249; minx 71; maxx 772;
   sname "Timpani"; pagen 1; sbarn 1;
<div class="bracket">
  ...

JavaScript

$('div[class^="stff"]').each(function() {
    var joined = $(this).html().match(/join/gi);
    if (joined) {
    $(this).addClass("joined");
    } else {
    $(this).addClass("system_end");
    }
});
  
 $('.joined:nth-child(1), .system_end + .joined').each(function() {
 $(this).nextUntil('.system_end + div').andSelf().wrapAll('<div class="system"></div>');
  });
  //$('.score > .system_end + .system_end, .score > .system_end:nth-child(1), .score > .system_end').wrap('<div class="system"></div>');

$('div[class^="stff"]').each(function() {
    $(this).removeClass("joined");
    $(this).removeClass("system_end")
});

var a = [];
$('.system > div').each(function(){
    var all_instruments = $(this).attr('class');
    a.push(all_instruments);
    //var filter = function(value, index){ return this.indexOf(value) == index };
		//var filteredData = a.filter(filter, a );
});
var filter = function(value, index){ return this.indexOf(value) == index };
var filteredData = a.filter(filter, a );
console.log(filteredData);