我正在开发一个 android 应用程序,我想识别 EditText 内的链接。我有下一个在objective-c中工作的代码,我想用java来做。我想这将与向量(字符串链接 [])有关,但我不知道。
NSError *qwerror = nil;
NSRegularExpression *qwregex = [NSRegularExpression regularExpressionWithPattern:@"(http://\\w+.\\w+.\\w+.\\w+.\\w+.)" options:0 error:&qwerror];
NSArray *qwmatches = [qwregex matchesInString:textView.text options:0 range:NSMakeRange(0, textView.text.length)];
NSMutableArray *qwwords = [NSMutableArray array];
for (NSTextCheckingResult *qwmatch in qwmatches) {
NSRange qwwordrange = [qwmatch rangeAtIndex:1];
NSString *qwword = [textView.text substringWithRange:qwwordrange];
[qwwords addObject:qwword];
}
NSString *allLinks = [qwwords componentsJoinedByString:@" "];