Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-23-2005, 03:05 PM   PM User | #1
Shwaza
New Coder

 
Join Date: May 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Shwaza is an unknown quantity at this point
Counting Strings Found

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.
Shwaza is offline   Reply With Quote
Old 05-23-2005, 03:23 PM   PM User | #2
Kor
Red Devil Mod


 
Kor's Avatar
 
Join Date: Apr 2003
Location: Bucharest, ROMANIA
Posts: 8,478
Thanks: 58
Thanked 379 Times in 375 Posts
Kor has a spectacular aura aboutKor has a spectacular aura about
var nri=blah.split('i').length-1;
__________________
KOR
Offshore programming
-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
Kor is offline   Reply With Quote
Old 05-23-2005, 03:59 PM   PM User | #3
Shwaza
New Coder

 
Join Date: May 2005
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Shwaza is an unknown quantity at this point
Thanks a lot That works great
Shwaza is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:15 AM.


Advertisement
Log in to turn off these ads.