简体   繁体   中英

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

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 RegexKitLite. Any help would be appreciated. Thanks

Use NSString 's stringByReplacingOccurrencesOfString:withString: method:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM