
var md = 'bla bla bla [rel link 1](@2.1) bla bla [link 2](@3.4)'


function extractRelativeLinks(remaining) {
  var re=/\[[a-zA-Z0-9\s]+\]\(@\d+\.\d+\)/
  var matches;
  var firstMatch;
  var matchIndex;
  var remaining;
  var bits = [];
  var beforeMatch;

  while(1) {

    matches = re.exec(remaining);
    if(! matches) {
      break;
    }
    firstMatch = matches[0];
    matchIndex = remaining.indexOf(firstMatch);
    beforeMatch = remaining.slice(0, matchIndex);
    remaining = remaining.slice(firstMatch.length + matchIndex);
    bits.push({
      md: beforeMatch
    });
    bits.push({
      link: firstMatch
    });

  }

  return bits;

}

console.log(extractRelativeLinks(md));