re全体换,js replaceAll

<html>
<head>
<script>
  var a = "123\nsdf\n3\n4";
  a=a.replace(/\n/g,',')
  alert(a)
</script>
</head>
<body>
<h2>方式是 :  / + [替换前字符] + /g  即可,注意,不要带引号</h2>
</body>
</html>

 

posted @ 2022-06-24 11:59  君子笑而不语  阅读(19)  评论(0编辑  收藏  举报