...

View Full Version : Counting Strings Found



Shwaza
05-23-2005, 03:05 PM
Hi, i'm wondering if anyone knows of a way to count how many times a certain string is found within a variable.

Say i had:

var blah="Here is a string";

And i wanted to count how many times it found an 'i' in that, how might i go about doing that?

Thanks.

Kor
05-23-2005, 03:23 PM
var nri=blah.split('i').length-1;

Shwaza
05-23-2005, 03:59 PM
Thanks a lot :) That works great :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum