function fn ()
{
for (var i = 0;i < arguments.length;i++) {
Alert ("First" + (i+1) + "value of parameter:" +arguments[i]);
}
}
var str = ' <div id= ' {wo} ' >{ni}</div> ';
Str.replace (/{([a-z]+)}/ig, FN);
The first parameter is a matching string, such as {wo} and {ni};
The second argument can have 0-n, matching the first argument to a regular string of parentheses, such as Wo and NI in the first argument, to match ([a-z]+),
There are several groups of parentheses, then there are several parameters;
The third parameter is the location of the string to which the first argument matches, such as {wo} returning 9,{no} to return 16;
The fourth parameter is the string used to match, in this case the <div id= "{wo}" >{NI}</DIV>.
Look at an example
<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title> New Document </title>
<meta name= "generator" content= "EditPlus" >
<meta name= "Author" content= "" >
<meta name= "keywords" content= "" >
<meta name= "description" content= "" >
<script language= "Web Effects" type= "Text/javascript" >
String.prototype.replaceall = Stringreplaceall;
function Stringreplaceall (afindtext,areptext) {
var raregexp = new RegExp (afindtext.replace (/) [() []{}^$+-*?.] /]/g, "$"), "IG");
Return This.replace (Raregexp,areptext);
}
function Myreplace () {
var Content=document.getelementbyid ("Content"). Value;
var rel_con=content.replaceall ("$name", "wwww");
document.getElementById ("Content2"). Value=rel_con;
}
</script>
<body>
<input type= "text" id= "content" Name= "Contxt" value= "$name Customer Name"/> <input "button" type= "Replace"
Onclick= "Myreplace ()"/><br/>
<input type= "text" id= "Content2" value= ""/>
</body>