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 @ "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.

Here is a class on NSString that will be what you want.

  @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

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -