这样写
<script>
function a(v) {
  v += "."
  re = /-(\d[^\d])/g;
  while(re.test(v))
    v = v.replace(re,"-0$1");
  return v.substr(0,v.length-1);
}
alert(a("2003-1-1"));
alert(a("2003-11-1"));
alert(a("2003-1-11"));
</script>