var str = "4796#########3333@@@@@11232************12312";console.log(str.replace(/(\d+)(#+)(\d+)(@+)(\d+)(\*+)(\d+)/, "$1#$3@$5*$7"));