替换

<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <title>RegExp</title>
</head>
<body>

<script>
var reg=new RegExp("Paul","g"); 
var stringObj="Paul Paula paul sPaul Paul";
var newstr=stringObj.replace(reg,"Ringo");
alert(newstr);
</script>

</body>
</html>

结果

 

posted on 2018-11-01 21:14  笛赋山中人  阅读(99)  评论(0编辑  收藏  举报

导航