replace

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<button onclick="Function()">click  it</button>
<p id="demo">Paul,Paula,Pauline,paul,Paul</p>
<script>
function Function(){
var str="Paul,Paula,Pauline,paul,Paul";
var txt=str.replace(/\bPaul\b/g,"Ringo");
document.getElementById("demo").innerHTML=txt;
}
</script>
</body>
</html>

posted @ 2018-11-01 20:21  维尼,小熊  阅读(105)  评论(0编辑  收藏  举报