DJ said:
three words: Regexp::Common::URI
-jp
Hm, let me have a look again at what the OP wrote:
I am struggling way too much with this. Does someone have a regex that
will match any url-ish string like. Not worried about mail links.
http://sd.org
www.dssd.com
ibm.mil
https://sdsdsd.jobs
xyz.travel
Thanks!
I read this as: 'I want a RE that matches all of my example-URIs, because they
all look url-ish.' ( a very vague and, at least in my eyes, error-prone
criterium, tempting me to give this: /.*\.\w{2,6}/ as an answer). To the OP:
What, exactly, do you want to accomplish?
If my assumption of the OP's intention is correct, then you're out of luck with
Regexp::Common, as it will only match valid URIs, as shown here:
D:\Temp\test_area>cat stunks.pl
#!/usr/bin/perl
use warnings;
use strict;
use Regexp::Common qw/URI/;
chomp ( my @uris = ( <DATA> ) );
foreach ( @uris ) {
/$RE{URI}{-keep}/ ? print "Found: $1\n" : print "Discarding: $_\n";
}
__DATA__
http://sd.org
www.dssd.com
ibm.mil
https://sdsdsd.jobs
xyz.travel
D:\Temp\test_area>perl stunks.pl
Found:
http://sd.org
Discarding:
www.dssd.com
Discarding: ibm.mil
Discarding:
https://sdsdsd.jobs
Discarding: xyz.travel
If I did misunderstand the OP I sincerely apologize for jumping at you when you
were giving a perfectly valid Solution ( though I still see some issues coming
up with the https-uris... , but hey, here's where the Fun(tm) begins: hooking
your own REs into Regexp::Common :-> )
Greetings,
Andreas Pürzer