From a4eed96cc617405ce51dfed1b681b55c5a1e4dc8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bert=20M=C3=BCnnich?= Date: Sun, 6 Apr 2014 11:34:24 +0200 Subject: [PATCH] url-select: New default regex, fixes issue #47 --- url-select | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/url-select b/url-select index 6b7fe8c..fc333e9 100644 --- a/url-select +++ b/url-select @@ -70,10 +70,15 @@ sub on_start { $current++; } } else { - @{$self->{pattern}} = qr{( - (?:https?://|ftp://|news://|git://|mailto:|file://|www\.) - [\w\-\@;\/?:&=%\$_.+!*\x27(),~#]+[\w\-\@;\/?&=%\$_+!*\x27()~] - )}x; + @{$self->{pattern}} = qr{ + (?:https?://|ftp://|news://|mailto:|file://|\bwww\.) + [\w\-\@;\/?:&=%\$.+!*\x27,~#]* + ( + \([\w\-\@;\/?:&=%\$.+!*\x27,~#]*\) # Allow a pair of matched parentheses + | # + [\w\-\@;\/?:&=%\$+*~] # exclude some trailing characters (heuristic) + )+ + }x; } () @@ -234,7 +239,6 @@ sub select_next { do { my ($beg, $end) = ($-[0], $+[0]); - --$end if $& =~ /['")]$/; push @{$self->{found}}, [$line->coord_of($beg), $line->coord_of($end), substr($text, $beg, $end - $beg)]; } while ($text =~ /$pattern/g);