Regexp::IPv6(3pm)

πŸ’– Regexp::IPv6 πŸ’–

okay bestie, gather round, because this is the little Perl module that does one thing and does it flawlessly. It's Regexp::IPv6, a section 3pm Perl manual page, and it's basically the bouncer at the club door of your network code. πŸŽ€


✨ NAME ✨

Regexp::IPv6 β€” a regular expression for IPv6 addresses. that's it. that's the whole personality. πŸ‘‘


🌸 SYNOPSIS 🌸

the entire vibe in four lines, no notes:

use Regexp::IPv6 qw($IPv6_re);

$address =~ /^$IPv6_re$/ and print "IPv6 address\n";

like. slay. 🫢


πŸ¦‹ DESCRIPTION πŸ¦‹

so here's the tea β˜•: this module exports the $IPv6_re regular expression, and that regex matches any valid IPv6 address as described in "RFC 2373 - 2.2 Text Representation of Addresses" β€” but with the "::" part carved out. so if a string does not comply with that RFC, it gets rejected, no cap, the door stays shut. πŸ’€

and if you wanna match full strings β€” like, the whole thing, start to finish, no sneaky extra characters sneaking in β€” you use /^$IPv6_re$/. anchors, bestie. they're the moment. ✨

lowkey important: without the ^ and $ you're just vibing, not validating. main character energy requires boundaries. πŸ’…

Copyright (C) 2009, 2010 by Salvador FandiΓ±o (sfandino@yahoo.com)

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.

and then the best part, honestly: additionally, you are allowed to use the regexp generated by the module in any way you want, without any restriction. for instance, you are allowed to copy it verbating in your program. (that's their spelling, not mine, and I am respectfully leaving it exactly where it is 🫢 β€” the permission is what matters and the permission is generous.)


so yeah. one variable, one regex, RFC-accurate, and a license that literally tells you to go forth and copy it. iconic behaviour, honestly. 🌈

this has been Regexp::IPv6, perl v5.26.1, dated 2018-04-03 β€” mwah, sending you the biggest kiss, go validate some addresses bestie πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈ

πŸ“¦ where this page comes from