in reply to regex of a url

Despite asking for URL matching, I think you are looking for a domain name matcher. Try something like:
use Regexp::Common; if ($name =~ /^$RE{net}{domain}\z/) { ... }
Note that there is no requirement for a webserver to be on a domain starting with www.

Replies are listed 'Best First'.
Re: regex of a url
by Abigail-II (Bishop) on Feb 26, 2004 at 10:24 UTC
    Note that /^$RE{net}{domain}\z/ will match a string consisting of a single space (it does so because RFC 1035 says that's a valid domain). Use
    /^(?! )$RE{net}{domain}\z/ # Or /^$RE{net}{domain}{-nospace}\z/
    if you don't want to match single space strings.

    Abigail