Skip to content

Commit 5fcb5db

Browse files
author
mengyaoyao
committed
修改网址匹配正则
1 parent 522762a commit 5fcb5db

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

MYCoreText_Example/MYCoreTextLabel/MYCoretextResultTool.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ + (MYSubCoretextResult *)lastNorTextResult:(MYSubCoretextResult *)lastEmotionRes
268268
{
269269
NSMutableArray *weblinks = [NSMutableArray array];
270270
//正则匹配超链接
271-
NSString *linkRegex = @"((http[s]{0,1}|ftp)://[a-zA-Z0-9\\.\\-]+\\.([a-zA-Z]{2,4})(:\\d+)?(/[a-zA-Z0-9\\.\\-~!@#$%^&*+?:_/=<>]*)?)|(www.[a-zA-Z0-9\\.\\-]+\\.([a-zA-Z]{2,4})(:\\d+)?(/[a-zA-Z0-9\\.\\-~!@#$%^&*+?:_/=<>]*)?)";
271+
NSString *linkRegex = @"(http(s)?://)?([\\w-]+\\.)+[\\w-]+(/[\\w- ./?%&#=]*)?";
272272
NSRegularExpression *linkExpression = [NSRegularExpression regularExpressionWithPattern:linkRegex options:NSRegularExpressionCaseInsensitive error:nil];
273273
//遍历结果
274274
[linkExpression enumerateMatchesInString:rangeString options:NSMatchingReportCompletion range:NSMakeRange(0, rangeString.length) usingBlock:^(NSTextCheckingResult * _Nullable result, NSMatchingFlags flags, BOOL * _Nonnull stop) {

0 commit comments

Comments
 (0)