Let's assume I can have the following strings:
"hey @john..."
"@john, hello"
"@john(hello)"
I am tokenizing the string to get every word separated by a space:
[myString componentsSeparatedByString:@" "];
My array of tokens now contain:
@john...
@john,
@john(hello)
I am checking for punctation marks as follows:
NSRange textRange = [words rangeOfString:@","];
if(textRange.location != NSNotFound){ } //do something
For these cases. How can I make sure only @john is tokenized, while retaining the trailing characters:
...
,
(hello)
Note: I would like to be able to handle all cases of characters at the end of a string. The above are just 3 examples.