web-正则表达式

<!DOCTYPE html>
<html>
<body>

<button onclick="myFunction()">Try it</button>
<p id="demo">Paul PAULA paula paul paul</p>
<script>
function myFunction() {
    var str = document.getElementById("demo").innerHTML;
    var txt = str.replace(/\bpaul\b/g,"atm");
    document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
</html>
 
 

posted on 2018-11-17 11:37  逗。逗at  阅读(179)  评论(0编辑  收藏  举报

导航