2006-09-25から1日間の記事一覧

文字列からある文字が何個含まれているか数える

splitを使って String.prototype.countS = function(str) { return this.split(str).length-1; } matchを使って String.prototype.countM = function(str) { return this.match(RegExp(str,'g')).length; } replaceをつかって String.prototype.countR = fun…