Last active
August 29, 2015 14:02
-
-
Save st98/f0fe153d6871fa782625 to your computer and use it in GitHub Desktop.
n 文字ごとに文字列を挿入するヤツ。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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