I'm trying to parse the domain name out of some URLs. In the example data, my regex works fine on the first two URLs, but clips off the first two characters of the domain on the third example. My regex probably could be much better.

#!/usr/bin/perl

use strict;
use warnings;

my $regex = qr'http://\w+?\.?\w+?\.?(\w+\.com)';

while(<DATA>){
  if (/$regex/o){print "$1 \t $_"}
}

__DATA__
http://www.asldkjlkwerj.com/
http://w71r2xk22q1affwp1ewpjeee.alaskjhhawe.com/?
http://qwlkjekwl.com/?IJESRKUFZedFRCVFJYQV4cUFtY

Thanks for any pointers,
Mike

--

It is easier to change the specification to fit the program than vice versa.
  02:50:01 up 20 days, 23:41,  0 users,  load average: 0.21, 0.22, 0.24

 Linux Registered User #241685  http://counter.li.org

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to