【算法题】字符串分割(二)

在这里插入图片描述
在这里插入图片描述

    function solution(num, str) {
   
      const arry = str.split("-");
      const first = arry[0];
      const other = arry
        .map((item, index) => {
   
          return index > 0 ? item : "";
        })
        .join("")
        .replace(/.{3}/g, "$&-");
      const result = `${
     first}-${
     other}`;
      return result;
    }

相关推荐

  1. leetcode刷笔记 split() 分割字符串

    2023-12-05 22:20:07       45 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-05 22:20:07       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-05 22:20:07       100 阅读
  3. 在Django里面运行非项目文件

    2023-12-05 22:20:07       82 阅读
  4. Python语言-面向对象

    2023-12-05 22:20:07       91 阅读

热门阅读

  1. 仿QT信号与槽的简易框架

    2023-12-05 22:20:07       57 阅读
  2. apache-poi

    2023-12-05 22:20:07       58 阅读
  3. 【论文阅读笔记】清单

    2023-12-05 22:20:07       76 阅读
  4. 案例:某旅游文化开发公司的IT设备统一监控

    2023-12-05 22:20:07       55 阅读
  5. Docker常见面试题集锦

    2023-12-05 22:20:07       60 阅读