找出字符串中的网址
作者:
伏特加 | 来源:发表于
2016-05-07 15:11 被阅读43次NSString *regulaStr = @"\\bhttps?://[a-zA-Z0-9\\-.]+(?::(\\d+))?(?:(?:/[a-zA-Z0-9\\-._?,'+\\&%$=~*!():@\\\\]*)+)?";
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:regulaStr
options:NSRegularExpressionCaseInsensitive
error:&error];
NSArray *arrayOfAllMatches = [regex matchesInString:string options:0 range:NSMakeRange(0, [string length])];
for (NSTextCheckingResult *match in arrayOfAllMatches)
{
NSString* substringForMatch = [string substringWithRange:match.range];
NSLog(@"substringForMatch%@",substringForMatch);
}
本文标题:找出字符串中的网址
本文链接:https://www.haomeiwen.com/subject/satsrttx.html
网友评论