代码编辑器:
x
1
<script>
2
var str="Every man in the world! Every woman on earth!";
3
var patt=/man/g;
4
var str2=str.replace(patt,"person");
5
document.write(str2+"<br>");
6
patt=/(wo)?man/g;
7
patt.compile(patt);
8
str2=str.replace(patt,"person");
9
document.write(str2);
10
</script>
11