Something similar to this, How to check if the URL contains a given string?
but is there a way to check if the URL contains a slash (/) more than 3 times, for example?
Thanks!
Something similar to this, How to check if the URL contains a given string?
but is there a way to check if the URL contains a slash (/) more than 3 times, for example?
Thanks!
This is one possibility, all characters that are not "/" are removed, then the String.length is used to find how many characters remain.
Javascript
var url = "https://stackoverflow.com/questions/16449482/check-to-see-a-url-contains-a-certain-character-how-many-times";
console.log(url.replace(/[^\/]/g, "").length);
On jsfiddle
This is not the fastest method though, I just wanted to give an alternative to those that have already been suggested in a previous QA. I added it to the jsperf