I have a string as shown below,
NSString * aString = @"This is the #substring1 and #subString2 I want";
How can I select only the text starting with ‘#’ (and ends with a space), in this case ‘subString1’ and ‘subString2’?
Note: Question was edited for clarity
You can do this using an NSScanner to split the string up. This code will loop through a string and fill an array with substrings.
Here is how the code works:
substring. If either the # was the last character, or was immediately followed by a space, the method will return NO. Otherwise it will return YES.substringto thesubstringsarray.