JScript Language Reference 上的例子:function ReplaceDemo(){
var r, re; //Declare variables.
var ss = "The man hit the ball with the bat.\n";
ss += "while the fielder caught the ball with the glove.";
re = /The/g; //Create regular expression pattern.
r = ss.replace(re, "A"); //Replace "A" with "The".
return(r); //Return string with replacement made.
}
var r, re; //Declare variables.
var ss = "The man hit the ball with the bat.\n";
ss += "while the fielder caught the ball with the glove.";
re = /The/g; //Create regular expression pattern.
r = ss.replace(re, "A"); //Replace "A" with "The".
return(r); //Return string with replacement made.
}
s="aa2aa3aau"
s=s.replace(aa,'happy')
s = s.replace(/aa/g, "happy");
真厉害!