Please check the following snippet:
const s="marks_old_100";
// remove any number
console.log(s.replace(/_[0-9]+$/, ''));
// remove three digit number
console.log(s.replace(/_[0-9]{3}$/, ''));
// remove _100, _150, _num
console.log(s.replace(/_(100|150|num)$/, ''));
solved Remove “_100” or “_150” or “_num” alone from the end of string [duplicate]