Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Regex for IPv6

by fuzzyping (Chaplain)
on Jan 27, 2004 at 16:49 UTC ( #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

Comment on Regex for IPv6
Download Code
Re: Regex for IPv6
by BrowserUk (Pope) 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
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? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-12-27 11:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls