码迷,mamicode.com
首页 > 其他好文 > 详细

以绅士的风范每隔四位插入一个空格

时间:2019-10-19 12:50:10      阅读:71      评论:0      收藏:0      [点我收藏+]

标签:rtsp   int   div   tsp   bsp   replace   turn   pre   ring   

function insertSpacesIntoString( s, defVal ) {
 return s && (function( s ) {
  return s.length > 4 && (s
   .replace(/\s/g,‘‘)
   .replace(/(.{4})/g,‘$1 ‘))
   .replace(/(\s*$)/g,‘‘)
   || s
  ;
 }(s.toString())) || defVal || ‘‘;
}

 

以绅士的风范每隔四位插入一个空格

标签:rtsp   int   div   tsp   bsp   replace   turn   pre   ring   

原文地址:https://www.cnblogs.com/houkaihua/p/11703352.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!