2010-11-22 4 views
0
Hi Friends, I have a small question, 

I have a paragraph of string, now I want to delete some words from that para 

aaaaaaaaaaaaaaaaa*bbbbbbbbb*aaaaaaaaaaaaaa. 
Now, suppose I want to delete the "bbbbbbbb" fromthe above para and I am using the following method 

mySpeechText = [[mySpeechText stringByReplacingOccurrencesOfString:strTemp withString:@""] retain]; 

but this method is replacing the "bbbbbbbb" with blank spaces, ie, "  " and I am getting 
aaaaaaaaaaaaaaaa  aaaaaaaaaaaaaaaaaa; 

and I want aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa; without any space. so how can I delete the "bbbbbbbb" rather replacing it. Thanks- 

If I am not clear plz let me know. 
+1

stringByReplacingOccurrencesOfString fonctionne bien pour moi. Je ne reçois aucun espace entre les caractères .. pouvez-vous mettre à jour la question avec votre méthode complète. –

+0

@Anil: Merci Anil, Ci-dessus est la méthode complète. Je remplace simplement le "bbbbbbb" par "" dans un paragraphe particulier mais il me donne "" :-). son étrange – Developer

+0

Je suppose que vous supprimez correctement le strTemp, mais en quelque sorte négliger un espace pré ou successif. –

Répondre

0

Essayez cette

mySpeechText=[mySpeechText stringByTrimmingCharactersInSet: 
       [NSCharacterSet characterSetWithCharactersInString:@"bbbbbbbb"]]; 
Questions connexes