alert("2014-03-22".replace('-','')); alert("2014-03-22".replace(/-/g,''));
第一个运行的结果"201403-22"这个只是替换了第一个"-"
第二个运行的结果"20140322" 这个能实现js的全部替换功能
其实第二个的意思就是用正则表达式实现全局的替换 g 代表 gobal