Is regex possible to calculate and to count a specific character in a string?
For instance the string value "asdfasdfasdf" and you want to count how many "a" in the value?
Tried to find a solution but I cant find one.
Is regex possible to calculate and to count a specific character in a string?
For instance the string value "asdfasdfasdf" and you want to count how many "a" in the value?
Tried to find a solution but I cant find one.
You can use match()
var count = "asdfasdfasdf".match(/a/g).length;
alert(count);