<html>
<body>

<script type="text/javascript">

var str="Microsoft hdh Microsoft";
document.write(str.replace(/Microsoft/g,"W3School"))

</script>
</body>
</html>

当加入/g后,就是匹配所有,不加的时候只是匹配第一个

相关文章:

猜你喜欢
  • 2022-12-23
  • 2021-06-16
  • 2021-09-21
相关资源
相似解决方案