Q:

Create Array of Twitter Handles from String

I'm looking for a way to analyze a string and create an array of all @Handles (like Twitter). With one small twist, @Handles can contain periods "."
So: @Username, @User_Name, or @User.Name.
My approach is with RegEx but I seem to be running into an error that I'm not sure how I'm producing.
My string is "@Albert and @David_Man and @Bob.Joe" but the array of usernames being returned is "@Albert, @David, @Bob", the RegEx is ignoring the underscores and periods.
Here is my code:
NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"@([a-zA-Z0-9_\\.]{0,30})" options:NSRegularExpressionCaseInsensitive error:&error];
NSArray *matches = [regex matchesInString:myString options:0 range:NSMakeRange(0, myString.length)];

A:

May be you should try this...
NSRegularExpression *regexForUserNameTag = [NSRegularExpression regularExpressionWithPattern: @"@[A-Za-z0-9._]{0,30}" options:0 error:&error];
NSArray *matchesUserName = [regexForUserNameTag matchesInString:yourString options:0 range:NSMakeRange(0, yourString.length)];
for (NSTextCheckingResult *match in matchesUserName) {
    NSRange wordRange = [match rangeAtIndex:0];
    NSString* word = [yourString substringWithRange:wordRange];
    [usernames addObject: word];
}

