[英]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.
同样,这需要用objective-c或c编写。
NSString *string = @"Word Word2";
I'm needing an expression to do this and I can't seem to grasp RegexKitLite. 我需要一个表达式来执行此操作,我似乎无法掌握RegexKitLite。 Any help would be appreciated.
任何帮助,将不胜感激。 Thanks
谢谢
Use NSString
's stringByReplacingOccurrencesOfString:withString:
method: 使用
NSString
的stringByReplacingOccurrencesOfString:withString:
方法:
NSString *spaceReplacement = @"whatever";
NSString *replaced = [string stringByReplacingOccurrencesOfString:@" " withString:spaceReplacement];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.