Is there a way to count the number of certain characters in a string?
For example : how many occurrences of characters 'a', '?', '<' in the string "Hello, are you here??".
So far, doper only with regular expressions, it works, (correct? or is there another way?):
var my_text = document.getElementById('myTextArea'); var result = my_text.value.match(/[a\?\<]/g).length;
Everything is processed by onkeyup when typing, any comments will be welcome.
("Hello, are you here??".split("a").length - 1);