Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Regexp::Common

by Anonymous Monk
on Feb 26, 2005 at 11:24 UTC ( [id://434763]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I am learning Perl.

What are the useful of Regexp::Common module.

Can u give small Coding.. So that it'll be very Helpfull to develop further...

Thanks So Much!!

Replies are listed 'Best First'.
Re: Regexp::Common
by holli (Abbot) on Feb 26, 2005 at 12:28 UTC
    I recommend reading the documentatin of the module. Many examples there are.


    holli, /regexed monk/
Re: Regexp::Common
by sh1tn (Priest) on Feb 26, 2005 at 14:03 UTC
      Urg. Those are test scripts that seem to generate all (or most) of the tests on the fly. Not very useful as examples. Most of what's found in the /t directory of Regexp::Common looks freakish - not the place I'd go to to get examples.
Re: Regexp::Common
by jmccarrell (Novice) on Sep 28, 2007 at 06:22 UTC
    Here's a practical example:
    use strict; use warnings; use Regexp::Common qw(URI); my @test_uris = ( # http 'http://search.cpan.org/~abigail/Regexp-Common-2.120/lib/Regexp/C +ommon/URI.pm', 'https://your.bank.com/', # ftp 'ftp://ftp.server.com/notepad', 'ftp://ftp.server.com/notepad/notepad.cpp', 'ftp://jrs@ftp.server.com/notepad/notepad.cpp', 'ftp://jrs:wibble@ftp.server.com/notepad/notepad.cpp', 'ftp://jrs:*@ftp.server.com/notepad/notepad.cpp', # file 'file:///C:/jwmhome/www/perl/index.html', # nntp & news 'news:/comp.lang.*', 'news:/comp.*.java*', 'news:/*.religion.bahai,!talk.*', 'nntp://server.example/comp/lang.c', 'nntp://server.example/comp/lang.c/125-237', 'nntp://server.example/comp/lang.c/125-', 'nntp://server.example/comp/lang.c/-237', # bad http / https 'xhttp://search.cpan.org/~abigail/Regexp-Common-2.120/lib/Regexp/ +Common/URI.pm', '<https://search.cpan.org/~abigail/Regexp-Common-2.120/lib/Regexp +/Common/URI.pm', # bad ftp 'xftp://ftp.server.com/notepad', '<ftp://ftp.server.com/notepad/notepad.cpp', '$ftp://jrs@ftp.server.com/notepad/notepad.cpp', '%ftp://jrs:wibble@ftp.server.com/notepad/notepad.cpp', ']ftp://jrs:*@ftp.server.com/notepad/notepad.cpp', ); for (@test_uris) { next if (/\A$RE{URI}{HTTP}{-scheme => qr(https?)}/ or /\A$RE{URI}{FTP}/ # or /$RE{URI}{file}/ # or /$RE{URI}{news}/ # or /$RE{URI}{NNTP}/ ); print 'not a URI: ', substr($_, 0, 40), "\n"; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://434763]
Approved by Elijah
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-04-25 17:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found