开发者

How to delete particular string from paragraph

开发者 https://www.devze.com 2023-01-26 20:00 出处:网络
Hi Friends, I have a small question, I have a paragraph of string, now I want to delete some words from that para
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

开发者_JAVA百科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.


Try this

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

精彩评论

暂无评论...
验证码 换一张
取 消