<div class="cnblogs_Highlighter">
<pre class="brush:javascript;gutter:true;"> function getYourString(s) {
var res = '';
var length = s.length;
for (var i = 0,j = 1; i < length; i++,j++) {
//每到达5次,添加一个换行标签
if (j && j % 6 == 0) {
res += '
';
} else {
res += s[i];
}
}
return res;
}
var test = '123456534545435435435';
document.write(getYourString(test));