JSFiddle - React, Tailwind, and code Playground
JavaScript
var str = '00000-001->22222-222';
var limpa = str.replace(/\-/g, function(match, pos) {
return str.slice(pos + 1, pos + 2).match(/\d/) ? '' : '-';
});
console.log(limpa); // dá 00000001->22222222