繁体   English   中英

如何使用RegexKitLite删除任意两个单词之间的空格/空白?

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

我想删除任何两个单词之间的空格并添加我想要的任何内容。 例如,我将有一个字符串,其中包含两个单词,两个单词之间有一个空格。 我希望能够删除该空间并用我声明的内容替换该空间。 同样,这需要用objective-c或c编写。

NSString *string = @"Word Word2";

我需要一个表达式来执行此操作,我似乎无法掌握RegexKitLite。 任何帮助,将不胜感激。 谢谢

使用NSStringstringByReplacingOccurrencesOfString:withString:方法:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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