Edit in JSFiddle

let cprPattern = /([0-9]{2})([0-9]{2})([0-9]{2})-([0-9]{4})/;
match = "100688-2105".match(cprPattern);
// eller 
// const match = cprPattern.exec("100688-2105");

if (match){
 console.log(match[1]+'-'+match[2]+'-'+match[3]+ " ("+ match[4] + ")");
}

console.log('100688-2105'.replace(
    cprPattern,`$1-$2-$3 ($4)`
));

cprPattern = /(?<day>[0-9]{2})(?<month>[0-9]{2})(?<year>[0-9]{2})-(?<number>[0-9]{4})/;

let backReference = /(?<day>[0-9]{2})(?<month>[0-9]{2})(?<year>[0-9]{2})-(?<number>[0-9]{4}). Født (19|20)\k<year>/;

match = "100688-2105. Født 1988".match(backReference);
if (match){
 const day = match.groups.day; 
 const month = match.groups.month;
 const year = match.groups.year; 
 const number = match.groups.number;
 console.log(`${day}-${month}-${year} (${number})`);
}

if (match) 
{
 const {groups: {day, month, year, number}} = match; 
 console.log(`${day}-${month}-${year} (${number})`);
}

if (match) 
{
 const [all, day, month, year, number] = match;
 console.log(`${day}-${month}-${year} (${number})`);
}

console.log('100688-2105'.replace(
    cprPattern,`$<day>-$<month>-$<year> ($<number>)`
));
    
console.log('100688-2105'.replace(
    cprPattern,
   (...args) => {
        const {day, month, year, number} = args[args.length-1];
        return `${day}-${month}-${year} (${number})`
    }));