nanog mailing list archives
Re: Regular Expression for IPv6 addresses
From: Richard.E.Brown () DARTWARE COM (Richard E. Brown)
Date: 06 Feb 2010 17:16:54 -0500
Folks, Thanks for all the comments on the IPv6 regex... -----
Jeroen Massar <jeroen () unfix org> wrote: The only proper way of "testing" if an address is a valid IPv6 address is to feed it to getaddrinfo() and then use it through that API.
Good point. One of the reasons to do this was for environments where getaddrinfo() might not be availble. (For example, in a Javascript - see the page on the InterMapper site: http://intermapper.com/ipv6validator )
Of course, there should be only limited places where a user can enter or see IP addresses in the first place. There is this great thing called DNS which is what most people should be using.
Another good point. But look at Seiichi's note (below)... -----
Seiichi Kawamura <kawamucho () mesh ad jp> also> wrote:
This might be of some interest to you. http://tools.ietf.org/html/draft-ietf-6man-text-addr-representation-04
We believe this correctly recognizes all the cases specified by RFC4291. But it's a great idea to update the Javascript page above to reformat to this recommendation.
-----
Carsten Bormann <cabo () tzi org> I was looking at this regexp for my Ruby course as a great example of "how not to use Regexps". But thank you for this textbook example! And, of course, an error did creep in.
You're quite welcome! :-) But seriously... Do you have an example of an address that causes the RE to fail?
If you really need an RE, the right approach here is to write a small program togenerate the RE.
Absolutely. The Perl program cited includes code much like your example. Rich Brown richard.e.brown () dartware com Dartware, LLC http://www.dartware.com 66-7 Benning Street Telephone: 603-643-9600 West Lebanon, NH 03784-3407 Fax: 603-643-2289PS Dartware is sponsoring a table displaying our InterMapper network monitoring software at the NANOG48 Beer 'n Gear. Please come by to introduce yourself and take a look...
Current thread:
- Re: Regular Expression for IPv6 addresses, (continued)
- Re: Regular Expression for IPv6 addresses Jeroen Massar (Feb 04)
- Re: Regular Expression for IPv6 addresses Mark Andrews (Feb 04)
- Re: Regular Expression for IPv6 addresses sthaug (Feb 04)
- Re: Regular Expression for IPv6 addresses James Hess (Feb 06)
- Re: Regular Expression for IPv6 addresses Mark Andrews (Feb 06)
- Re: Regular Expression for IPv6 addresses isabel dias (Feb 05)
- Re: Regular Expression for IPv6 addresses Thomas Habets (Feb 09)
- Re: Regular Expression for IPv6 addresses Mark Andrews (Feb 09)
- Re: Regular Expression for IPv6 addresses Valdis . Kletnieks (Feb 09)
