Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

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?



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.


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?

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
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (3)
As of 2023-03-31 11:41 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (75 votes). Check out past polls.