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

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 || '';
}
原文地址:https://www.cnblogs.com/houkaihua/p/11703352.html