开发者

How to remove space/blank between any two words using RegexKitLite?

开发者 https://www.devze.com 2023-01-31 17:33 出处:网络
I\'m wanting to remove a space between any two words and add anything that I want. For example, I\'ll have a string that has two words in it with a space between the two. I want to be able to remove t

I'm wanting to remove a space between any two words and add anything that I want. For example, I'll have a string that has two words in it with a space between the two. I want to be able to remove the space and replace the space with something that I declare. Also, this needs to be written in objective-c or c.

NSString *string = @"Word Word2";

I'm needing an expression to do this and I can't seem to grasp Re开发者_如何学PythongexKitLite. Any help would be appreciated. Thanks


Use NSString's stringByReplacingOccurrencesOfString:withString: method:

NSString *spaceReplacement = @"whatever";
NSString *replaced = [string stringByReplacingOccurrencesOfString:@" " withString:spaceReplacement];
0

精彩评论

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