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

Answer by Balaji Sukumaran for How to count string occurrence in string?

$
0
0

We can use the js split function, and it's length minus 1 will be the number of occurrences.

var temp = "This is a string.";alert(temp.split('is').length-1);

Viewing all articles
Browse latest Browse all 43

Trending Articles



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