-1

My Input file its a plain content:

Fries Scheepvaartmuseum: Schiffmodelle in jeglichen Größen und viele Infos über Schiffsbau und Seefahrt sowie über die Geschichte der Stadt Sneek. *www.friesscheepvaartmuseum.nl** Museen sowie facebook.com viele kleine Gassen zwischen den https://facebook.com Grachten locken zu Erkundungstouren. Der Strand lädt zu romantischen Spaziergängen ein https://stackoverflow.com/questions/tagged/perl nicht nur probieren und kaufen, sondern auch das nostalgische Haus und die Destillerie besichtigen stackoverflow.com/questions/tagged/perl

I can able to find www.<sample>.<edu|com|af|ag|ai|al|etc>, https?://<sample>.<edu|com|af|ag|ai|al|etc> with prefix (www, http) and suffix (list of domains).

However, I need to find the links based on the some list of domains like ... .edu, .com, .af, .ag, .ai, .al without prefix and suffix in the web links.

For example:

I couldn't able to find incomplete or without prefix www, https, http links like facebook.com, stackoverflow.com/questions/tagged/perl in a plain contents.

Could you please someone help me on this one if there is any module is available or any regex patterns would be helpful for me since I have more than 10k web links to find.

ssr1012
  • 2,573
  • 1
  • 18
  • 30

1 Answers1

1

Here is an example using URI::Find::Schemeless:

use feature qw(say);
use strict;
use warnings;
use URI::Find::Schemeless;

my $text = do { local $/; <DATA> };
my $finder = URI::Find::Schemeless->new(\&callback);
my $how_many_found = $finder->find(\$text);

sub callback {
    my ( $uri, $orig_text ) = @_;
    say "Found: ", $orig_text;
}

__DATA__
Fries Scheepvaartmuseum: Schiffmodelle in jeglichen Größen und viele Infos über Schiffsbau und Seefahrt sowie über die Geschichte der Stadt Sneek. *www.friesscheepvaartmuseum.nl** Museen sowie facebook.com viele kleine Gassen zwischen den https://facebook.com Grachten locken zu Erkundungstouren. Der Strand lädt zu romantischen Spaziergängen ein https://stackoverflow.com/questions/tagged/perl nicht nur probieren und kaufen, sondern auch das nostalgische Haus und die Destillerie besichtigen stackoverflow.com/questions/tagged/perl

Output:

Found: facebook.com
Found: https://facebook.com
Found: https://stackoverflow.com/questions/tagged/perl
Found: stackoverflow.com/questions/tagged/perl
Håkon Hægland
  • 39,012
  • 21
  • 81
  • 174