<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package Regexp::Common::URI;

use Regexp::Common qw /pattern clean no_defaults/;

use strict;
use warnings;

use Exporter ();
use vars qw /@EXPORT_OK @ISA/;

@ISA       = qw /Exporter/;
@EXPORT_OK = qw /register_uri/;

use Regexp::Common qw /pattern clean no_defaults/;

use strict;
use warnings;

use vars qw /$VERSION/;
$VERSION = '2010010201';

# Use 'require' here, not 'use', so we delay running them after we are compiled.
# We also do it using an 'eval'; this saves us from have repeated similar
# lines. The eval is further explained in 'perldoc -f require'.
my @uris = qw /fax file ftp gopher http pop prospero news tel telnet tv wais/;
foreach my $uri (@uris) {
    eval "require Regexp::Common::URI::$uri";
    die $@ if $@;
}

my %uris;

sub register_uri {
    my ($scheme, $uri) = @_;
    $uris {$scheme} = $uri;
}

pattern name    =&gt; [qw (URI)],
        create  =&gt; sub {my $uri =  join '|' =&gt; values %uris;
                           $uri =~ s/\(\?k:/(?:/g;
                      "(?k:$uri)";
        },
        ;

1;

__END__

=pod

=head1 NAME

Regexp::Common::URI -- provide patterns for URIs.

=head1 SYNOPSIS

    use Regexp::Common qw /URI/;

    while (&lt;&gt;) {
        /$RE{URI}{HTTP}/       and  print "Contains an HTTP URI.\n";
    }

=head1 DESCRIPTION

Patterns for the following URIs are supported: fax, file, FTP, gopher,
HTTP, news, NTTP, pop, prospero, tel, telnet, tv and WAIS.
Each is documented in the I&lt;Regexp::Common::URI::B&lt;scheme&gt;&gt;,
manual page, for the appropriate scheme (in lowercase), except for
I&lt;NNTP&gt; URIs which are found in I&lt;Regexp::Common::URI::news&gt;.

=head2 C&lt;$RE{URI}&gt;

Return a pattern that recognizes any of the supported URIs. With
C&lt;{-keep}&gt;, only the entire URI is returned (in C&lt;$1&gt;).

=head1 REFERENCES

=over 4

=item B&lt;[DRAFT-URI-TV]&gt;

Zigmond, D. and Vickers, M: I&lt;Uniform Resource Identifiers for
Television Broadcasts&gt;. December 2000.

=item B&lt;[DRAFT-URL-FTP]&gt;

Casey, James: I&lt;A FTP URL Format&gt;. November 1996.

=item B&lt;[RFC 1035]&gt;

Mockapetris, P.: I&lt;DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION&gt;.
November 1987.

=item B&lt;[RFC 1738]&gt;

Berners-Lee, Tim, Masinter, L., McCahill, M.: I&lt;Uniform Resource
Locators (URL)&gt;. December 1994.

=item B&lt;[RFC 2396]&gt;

Berners-Lee, Tim, Fielding, R., and Masinter, L.: I&lt;Uniform Resource
Identifiers (URI): Generic Syntax&gt;. August 1998.

=item B&lt;[RFC 2616]&gt;

Fielding, R., Gettys, J., Mogul, J., Frystyk, H., Masinter, L., 
Leach, P. and Berners-Lee, Tim: I&lt;Hypertext Transfer Protocol -- HTTP/1.1&gt;.
June 1999.

=item B&lt;[RFC 2806]&gt;

Vaha-Sipila, A.: I&lt;URLs for Telephone Calls&gt;. April 2000.

=back

=head1 SEE ALSO

L&lt;Regexp::Common&gt; for a general description of how to use this interface.

=head1 AUTHOR

Damian Conway (damian@conway.org)

=head1 MAINTAINANCE

This package is maintained by Abigail S&lt;(I&lt;regexp-common@abigail.be&gt;)&gt;.

=head1 BUGS AND IRRITATIONS

Bound to be plenty.

For a start, there are many common regexes missing.
Send them in to I&lt;regexp-common@abigail.be&gt;.

=head1 LICENSE and COPYRIGHT

This software is Copyright (c) 2001 - 2009, Damian Conway and Abigail.

This module is free software, and maybe used under any of the following
licenses:

 1) The Perl Artistic License.     See the file COPYRIGHT.AL.
 2) The Perl Artistic License 2.0. See the file COPYRIGHT.AL2.
 3) The BSD Licence.               See the file COPYRIGHT.BSD.
 4) The MIT Licence.               See the file COPYRIGHT.MIT.

=cut
</pre></body></html>