如何从段落中删除特定字符串

时间:2010-11-22 06:20:35

标签: iphone

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 个答案:

答案 0 :(得分:0)

试试这个

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