Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 02-09-2010, 03:02 AM   #2 (permalink)
reena
Reena
 
Join Date: Apr 2009
Posts: 31
Default

Quote:
Originally Posted by rahul View Post
Can any one help me to find out count of occurrences substring within a string.

NSString *str = @"The Quick Brown Fox Brown";

i want count of occurrence of word "Brown" from above string.

Thanks

NSString *str = @"The Quick Brown Fox Brown";
NSInteger count = 0;
NSArray *arr = [str componentsSeparatedByString:@" "];
for(int i=0;i<[arr count];i++)
{
if([[arr objectAtIndex:i] isEqualToString:@"Brown"])
count++;
}
reena is offline   Reply With Quote
 

» Advertisements
» Online Users: 818
26 members and 792 guests
acegames, ADY, aslyworo, ckgni, dabvid, dfvdan, GFish, GHuebner, ghz.rai, ilmman, iph_s, joeallenpro, john love, keeshux, marcelglaeser, marto1914, Ndpiparava, nfung, nru, Pandafox, RoryHarvey, tomtom100, VikMyr, waq963, _Mac
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,869
Threads: 89,225
Posts: 380,692
Top Poster: BrianSlick (7,129)
Welcome to our newest member, aslyworo
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:34 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.