You can use NSDataDetectors . They were added in iOS4 and are very useful. You want to create a data detector using NSTextCheckingTypeLink and let it do it.
NSString *testString = @"Hello http://google.com world"; NSDataDetector *detect = [[NSDataDetector alloc] initWithTypes:NSTextCheckingTypeLink error:nil]; NSArray *matches = [detect matchesInString:testString options:0 range:NSMakeRange(0, [testString length])]; NSLog(@"%@", matches);
Joshua weinberg
source share