张赐荣——一位视障程序员。
赐荣小站: www.prc.cx

張賜榮

张赐荣的技术博客

博客园 首页 新随笔 联系 订阅 管理

使用 拆分-连接替换法替换所有子字符串

<script type="text/javascript">
alert(replaceAll("苹果,男孩,猫,狗,蛋",",","、"));  // 苹果、男孩、猫、狗、蛋

function replaceAll(text,find,replace)
{
var stringList = text.split(find);
return(stringList.join(replace));
}
</script>
posted on 2022-05-24 21:54  张赐荣  阅读(54)  评论(0编辑  收藏  举报

感谢访问张赐荣的技术分享博客!
博客地址:https://cnblogs.com/netlog/
知乎主页:https://www.zhihu.com/people/tzujung-chang
个人网站:https://prc.cx/