Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

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 (Pope) 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
Node Status?
node history
Node Type: perlquestion [id://324473]
Approved by particle
Front-paged by broquaint
[LanX]: ehm ... nope ... a PM discussion not a meditation
[LanX]: I spend too much time in this alsmhouse ... cheers o/
[Discipulus]: what articular point of view.. i intrepreted the only question mark as rethoric.. but i'm strange

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (8)
As of 2017-11-23 20:08 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (337 votes). Check out past polls.