Find and replace long words in an NSString? [closed]
问题 I'm trying to write a method that will search an NSString, determine if an individual word within the string is over 6 characters long and replace that word with some other word (something arbitrary like 'hello'). I am starting with a long paragraph and I need to end up with a single NSString object whose format and spacing has not been affected by the find and replace. 回答1: Why another answer? There are a couple of subtle problems with the simple solutions using componentsSeparatedByString: