function replace(str) { let n = 0; return str.replace(/\d+/g, m => n++ ? '' : m); } alert(replace("/&fff7321вв/;/jjj123;gggg456"));