use URI::Find
#/usr/bin/perl
my $text = 'https://twinkle.cc/i/';
my $url = getURL($text);
sub getURL {
use URI::Find;
my $text = shift;
my $finder = URI::Find->new(
sub {
my($uri, $orig_uri) = @_;
return $uri;
});
$finder->find(¥$text);
my $http_URL_regex =
q{¥b(?:https?|shttp)://(?:(?:[a-zA-Z0-9](?:[-a-zA-Z0-9]*[a-zA-Z0-9])} .
q{?¥.)*[a-zA-Z](?:[-a-zA-Z0-9]*[a-zA-Z0-9])?¥.?|[0-9]+¥.[0-9]+¥.[0-9} .
q{]+¥.[0-9]+)(?::[0-9]*)?(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-F} .
q{a-f][0-9A-Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0} .
q{-9A-Fa-f])*)*(?:/(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-} .
q{Fa-f])*(?:;(?:[-_.!~*'()a-zA-Z0-9:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f])} .
q{*)*)*(?:¥?(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-f} .
q{])*)?)?(?:#(?:[-_.!~*'()a-zA-Z0-9;/?:@&=+$,]|%[0-9A-Fa-f][0-9A-Fa-} .
q{f])*)?(?![-_.!~*'()a-zA-Z0-9;/?:@&=+$,#])}; #}}
return $text =~ /($http_URL_regex)/ ? $1 : '';
}
1;