例如,我如何知道“hello world”字符串包含三个字母l?
答案 0 :(得分:1)
var hm:int = 0;
var index:int = 0;
while ((index = your_string.indexOf(your_substring, index)) != -1) {
index++;
hm++;
}
trace('how many: ' + hm);
答案 1 :(得分:1)
易:
your_string.match( your_substring ).length;
或俗气:
your_string.split( your_substring ).length - 1;