Quantcast
Channel: How to count string occurrence in string? - Stack Overflow
Viewing all articles
Browse latest Browse all 43

Answer by mendezcode for How to count string occurrence in string?

$
0
0
 function substrCount( str, x ) {   let count = -1, pos = 0;   do {     pos = str.indexOf( x, pos ) + 1;     count++;   } while( pos > 0 );   return count; }

Viewing all articles
Browse latest Browse all 43

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>