本文介绍了iPhone dev:用空格和小写替换NSString中的大写字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有:
NSString *promise = @"thereAreOtherWorldsThanThese";
我正在尝试转换成字符串:
which I'm trying to transform into the string:
@"There are other worlds than these"
I'm guessing this is a regex job, but I'm very new to Objective C, and have so far had no luck. I would greatly appreciate any help!
推荐答案
我使用 GTMRegex
(),例如:
NSString *promise = @"thereAreOtherWorldsThanThese";
GTMRegex *regex = [GTMRegex regexWithPattern:@"([A-Z])"];
NSLog(@"%@", [[regex stringByReplacingMatchesInString:promise
withReplacement:@" \\1"] lowercaseString]);
这篇关于iPhone dev:用空格和小写替换NSString中的大写字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!