| */ | |
| function occurrences(string, subString, allowOverlapping) { | |
| string += “”; | |
| subString += “”; | |
| if (subString.length <= 0) return (string.length + 1); | |
| var n = 0, | |
| pos = 0, | |
| step = allowOverlapping ? 1 : subString.length; | |
| while (true) { | |
| pos = string.indexOf(subString, pos); | |
| if (pos >= 0) { | |
| ++n; | |
| pos += step; | |
| } else break; | |
| } | |
| return n; | |
| } |
2 comments On giai ho tui
Thank you for your sharing. I am worried that I lack creative ideas. It is your article that makes me full of hope. Thank you. But, I have a question, can you help me?
Thanks for sharing. I read many of your blog posts, cool, your blog is very good.