Regexp::IPv4 - Regular expression for IPv4 addresses
This document describes version 0.003 of Regexp::IPv4 (from Perl distribution Regexp-IPv4), released on 2016-10-18.
use Regexp::IPv4 qw($IPv4_re); $address =~ /^$IPv4_re$/ and print "IPv4 address\n";
The regex only recognizes the quad-dotted notation of four decimal integers, ranging from 0 to 255 each. Other notations like 32-bit hexadecimal number (e.g. 0xFF0000) or shortened dotted notation (e.g. 255.0.0) are not recognized.
If you do not use anchor, beware of cases like:
"255.255.255.256" =~ /($IPv4_re)/; # true & capture "255.255.255.25"
Please visit the project's homepage at https://metacpan.org/release/Regexp-IPv4.
Source repository is at https://github.com/perlancar/perl-Regexp-IPv4.
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=Regexp-IPv4
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
Regexp::IPv6
perlancar <perlancar@cpan.org>
This software is copyright (c) 2016 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Regexp::IPv4, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Regexp::IPv4
CPAN shell
perl -MCPAN -e shell install Regexp::IPv4
For more information on module installation, please visit the detailed CPAN module installation guide.