Objective-C 使用大小写分割字符串

NSString *string = @"ThisStringIsJoined";
NSRegularExpression *regexp = [NSRegularExpression 
	regularExpressionWithPattern:@"([a-z])([A-Z])" 
	options:0 
	error:NULL];
NSString *newString = [regexp 
	stringByReplacingMatchesInString:string 
	options:0 
	range:NSMakeRange(0, string.length) 
	withTemplate:@"$1 $2"];
NSLog(@"Changed '%@' -> '%@'", string, newString);

输出:

'ThisStringIsJoined' -> 'This String Is Joined'

From: http://stackoverflow.com/a/7322720/892056

Written on 2016-02-17