var add='1999-06-15'
var ss=add.replace(/(\d{4})-(\d{2})-(\d{2})/g,$1)
alert(ss);
$1需要引号
你可以在给正则表达式加上边界:
/ ^( \d{4} ) - ( \d{2} ) - ( \d{2} )$ /g
var add = '1999-06-15'
var ss = add.replace(/(\d{4})-(\d{2})-(\d{2})/g, "$1")