var s = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ01234567890';
      function f(s, width){
        return s.replace(
        new RegExp('[\\s\\S]{1,'+(width || 4)+'}', 'g'),
        function(m){
          return '^' + new Array(m.length).join(' ');
        });
      }

      console.log(s);
      console.log(f(s, 4));
      console.log(f(s, 8));

相关文章:

  • 2021-08-05
  • 2022-01-27
  • 2021-07-05
  • 2022-01-17
  • 2022-02-04
  • 2022-12-23
  • 2021-07-13
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
相关资源
相似解决方案