I have some text loaded into NSString objects which contains annotations in square brackets – I need to strip the square brackets and everything within them so the user is only presented with the body text.
However, because of the reliance of Objective-C on square brackets for messaging etc…, I’m having a bit of a problem removing them.
Is there some special escape character for using square brackets (for example as an argument to ‘rangeOfString:’)? Xcode repeatedly informs me that there isn’t.
Cheers
You can use regular expressions to remove substrings you want:
P.S. You may need to adjust regexp pattern if your annotations may contain characters that not match ‘\w’ specifier