Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xx19941215/078a45facdc1689e998d8e0dcd5c1481 to your computer and use it in GitHub Desktop.
Save xx19941215/078a45facdc1689e998d8e0dcd5c1481 to your computer and use it in GitHub Desktop.
按照指定长度间隔分割字符串.js
let func = (source, count) => {
let arr = [];
for (let i = 0, len = source.length / count; i < len; i++) {
let subStr = source.substr(0, count);
arr.push(subStr);
source = source.replace(subStr, "");
}
return arr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment