Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function searchSubstr( fullText, searchText, allowOverlap ){
- if(!searchText){return 0;}
- var regex = new RegExp(searchText, 'igm'), count=0, substr;
- while(substr=regex.exec(fullText)){
- count++;
- if(allowOverlap!==false){
- regex.lastIndex -= Math.ceil(substr.length/2);
- }
- }
- return count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement