How to find the String Count in a String in JavaScript?
Ex:
https://localhost/public/10e900fe-0470-11eb-93c6-f377ab03a336//
Get the // occurrence count.
How to find the String Count in a String in JavaScript?
Ex:
https://localhost/public/10e900fe-0470-11eb-93c6-f377ab03a336//
Get the // occurrence count.
 
    
    var string = "https://localhost/public/10e900fe-0470-11eb-93c6-f377ab03a336//";
console.log((string.match(/\/\//g) || []).length);You can try below code:
var string = "https://localhost/public/10e900fe-0470-11eb-93c6-f377ab03a336//";
console.log((string.match(/\/\//g) || []).length);
 
    
     
    
    var a="https://localhost/public/10e900fe-0470-11eb-93c6-f377ab03a336//"
var count= a.split("//").length-1;
console.log(count)you can find the count by splitting it into an array and find the length of the array
var a="https://localhost/public/10e900fe-0470-11eb-93c6-f377ab03a336//"
var count= a.split("//").length-1; // its 2
 
    
    