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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 11-08-2009, 08:51 AM   #1 (permalink)
AndrewSpeaksOut
Registered Member
 
AndrewSpeaksOut's Avatar
 
Join Date: Sep 2009
Location: Tennessee
Posts: 14
AndrewSpeaksOut is on a distinguished road
Question Removing all punctuation and placing remaining words into array

I'm trying to take the text typed or pasted into a searchbar and remove all punctuation and separate each individual word and place it in an array. This is as close as I've gotten but there are a lot of empty entries in the array where the punctuation was.

Code:
NSString *sourceData = source.text;
NSString *filteredData = [[sourceData componentsSeparatedByCharactersInSet:[[NSCharacterSet letterCharacterSet] invertedSet]] componentsJoinedByString:@"_"];
NSArray *components = [filteredData componentsSeparatedByString:@"_"];
Code:
   S,
    "",
    history,
    "",
    affecting,
    "",
    "",
    "",
    states,
    over,
    an,
    area,
    of,
    "",
    "",
There must be a better way of doing this. I need a very efficient way.

Last edited by AndrewSpeaksOut; 11-08-2009 at 09:11 AM.
AndrewSpeaksOut is offline   Reply With Quote
 

» Advertisements
» Online Users: 601
19 members and 582 guests
.Snipe, Absentia, Aibo, anarkoly10, ayitiere, Brian965, haisergeant, Hassasin, hdeuwere, iphomh, matt2009, Paul Slocum, Rudy, skiril, skrew88, SLIC, Sophie100, st02197
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,319
Threads: 93,988
Posts: 402,409
Top Poster: BrianSlick (7,978)
Welcome to our newest member, st02197
Powered by vBadvanced CMPS v3.1.0

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