Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Regex for IPv6

by fuzzyping (Chaplain)
on Jan 27, 2004 at 16:49 UTC ( [id://324473]=perlquestion: print w/replies, xml ) Need Help??

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

I'm trying to match IPv6 addresses and having some difficulty. IPv4 is very standard and predictable, but the address architecture for IPv6 allows for a number of "short-hand" representations. It's entirely possible to see anything from :: to ::1 to 0:0:0:0:0:0:0:0. An example "short-hand" might be to represent FF01:0:0:0:0:0:0:101 as FF01::101.

I expect that I can use /\w*\:\w*\:\w*/ to verify the input line contains an actual IPv6 address, but I'll need to be able to extract the address. What could I use that would match 0:0:0:0:0:0:0:0 as well?

Thanks!

-fp

Replies are listed 'Best First'.
Re: Regex for IPv6
by BrowserUk (Patriarch) on Jan 27, 2004 at 17:06 UTC
      Yeah, I think the regex code from that will help out.

      Thanks!

      -fp
Re: Regex for IPv6
by halley (Prior) on Feb 06, 2004 at 13:00 UTC
    Hm, I think this IPv6 regex stuff should be tested and adopted in Regex::Common::net. I think Abigail is the maintainer of that package on CPAN.
    use Regex::Common; $x =~ /$RE{net}{IPv6}/;

    --
    [ e d @ h a l l e y . c c ]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (4)
As of 2024-04-19 06:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found