ios - Objective C : Separate words in a string and join again -
This question is already an answer here Is: <6 answers
I have a string Here is a class on NSString that will be what you want. @ "DidNotTurnUp" . I want to write a function that takes this string as an input and output should be
@ "not turned on" . What would be the best way to do this? How to separate words in a string based on capital letters? HELP appreciated.
@implementation NSString (SeparateCapitalizedWords) - (NSString *) stringBySeparatingCapitalizedWords {Fixed NSRegularExpression * __regex; Static transmissions_access_one talk; Dispatch_once (& amp; oneToken, ^ {NSError * error = zero; __regex = [NSRegularExpression regularExpressionWithPattern: @ "[P \\ {uppercase letter}]" option: 0 error: & amp; error], if (error) {@ Throw error;}}); NSString * Result = [__regex stringByReplacingMatchesInString: Self Option: 0 Range: (NSRange) {1, self.length - 1} withTemplate: @ "$ 0"]; Return result; } @end
Comments
Post a Comment