Js as a result of the String object only replace, but not replaceAll function, in the absence of awareness before the regexp is a string it is very difficult to all the objects are replaced one-time,
js design a long time ago, replace (reg, text), The first of these parameters, we generally used only when the partition at the actual, it is to support the regexp, and use of the overall regexp can easily attribute replaceAll, as long as some regexp basis, they will understand:

example: "2009-05-25" -> "2009_05_25"
var reg = / - / g;
var param = "2009-05-25";
var result = param.replace (reg, "_");

--------
result: 2009_05_25