Skip to content

Instantly share code, notes, and snippets.

@st98
Last active August 29, 2015 14:02
Show Gist options
  • Save st98/f0fe153d6871fa782625 to your computer and use it in GitHub Desktop.
Save st98/f0fe153d6871fa782625 to your computer and use it in GitHub Desktop.
n 文字ごとに文字列を挿入するヤツ。
String.prototype.n文字ごとに文字列を挿入する = function (n, str) {
if (n == null || str == null) {
return String(this);
}
return this.replace(new RegExp('.{' + n + '}', 'g'), function (m) {
return m + str;
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment