stringObj.replace(rgExp, replaceText)ArgumentsstringObj 
Required. The String object or string literal on which to perform the replacement. This string is not modified by the replace method. rgExp 
Required. An instance of a Regular Expression object containing the regular expression pattern and applicable flags. Can also be a String object or literal. If rgExp is not an instance of a Regular Expression object, it is converted to a string, and an exact search is made for the results; no attempt is made to convert the string into a regular expression. replaceText 
Required. A String object or string literal containing the text to replace for every successful match of rgExp in stringObj. In JScript 5.5 or later, the replaceText argument can also be a function that returns the replacement text.

解决方案 »

  1.   

    replace(regexp, replacement)函数的用法就是在使用该函数的字符串中找出函数中第一个参数(regexp)指定的字符(串),然后用该参数中第二个函数(replacement)所指定的字符(串)代替。函数中的两个参数可以是变量、正则表达式或者是字符串常量,如果测量器是IE5.5+和NS4.06+的话还可以是函数!如:
    var stringA = "abcdefg";
    var stringB = stringA.replace("abc","0");
    alert(stringA + "\n" + stringB);