Hi
I am trying to run a "Find and Replace" for individual words in an NSString. I want to basically say:
where I define a word as a block of text with a space on either side of it.
I'm getting my String from a textField with:
The two bits I am not sure about are:
1) How to split the string into individual words in such a way that I can recombine it later to make one string. Currently, I am splitting it with:
But I am not sure how to processs the text from there.
2) How to run an IF/ELSE that is based on the word length in an NSArray. I can do it for NSString, but getting individual components from an Array seems more difficult.
Can anybody point me in the direction of some documentation on how to do this, or give me a few pointers? I've done some research, but can't find anything to do with individually processing an NSArray.
Thanks in advance,
Sam
I am trying to run a "Find and Replace" for individual words in an NSString. I want to basically say:
Code:
IF words longer than 4 characters, do this method for this word.
ELSE do this method for this word.
I'm getting my String from a textField with:
Code:
input = textField.text;
1) How to split the string into individual words in such a way that I can recombine it later to make one string. Currently, I am splitting it with:
Code:
words = [input componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
2) How to run an IF/ELSE that is based on the word length in an NSArray. I can do it for NSString, but getting individual components from an Array seems more difficult.
Can anybody point me in the direction of some documentation on how to do this, or give me a few pointers? I've done some research, but can't find anything to do with individually processing an NSArray.
Thanks in advance,
Sam