Jump to content
Sign in to follow this  
Dwalfware

IPv6 regular expression

Recommended Posts

Does anyone know how to find IPv6 expression. 

I have Ipv4 but with IPv6 the address is never strait, some times you have 5 ":"  some times you have 7?

Local $aISITIPv4 = StringRegExp("192.168.0.1", "[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}+\.[0-9]{1,3}", 0)

any ideas how to code for below? Lost :sweating:  Point in right direction or tip please. Begging :lol:

2001:4860:4860::8888
2001:4860:4860::8844
2620:0:ccc::2
2620:0:ccd::2
2a02:6b8::feed:0ff
2a02:6b8:0:1::feed:0ff
2001:67c:28a4::
2002:d596:2a92:1:71:53::
2001:470:6c:521::2
2001:470:6d:521::1
2001:1608:10:25::1c04:b12f
2001:1608:10:25::9249:d69b
2001:910:800::12
2001:910:800::40
2606:4700:4700::1111
2606:4700:4700::1001
2610:a1:1018::1
2610:a1:1019::1
2610:a1:1018::5
2610:a1:1019::5
2a00:5a60::ad1:0ff
2a00:5a60::ad2:0ff
2a02:6b8::feed:a11
2a02:6b8:0:1::feed:a11
2a0d:2a00:1::
2a0d:2a00:2::
2a0d:2a00:1::1
2a0d:2a00:2::1
2610:a1:1018::3
2610:a1:1019::3
2610:a1:1018::4
2610:a1:1019::4
2a00:5a60::bad1:0ff
2a00:5a60::bad2:0ff
2a02:6b8::feed:bad
2a02:6b8:0:1::feed:bad
2a0d:2a00:1::2
2a0d:2a00:2::2
2610:a1:1018::2
2610:a1:1019::2

 

Share this post


Link to post
Share on other sites

Ok I think I cracked it

Does this look ok or will it fail on some weird Ipv6?

It failed :(

#include <StringConstants.au3>
Local $aISITIPv6a = StringRegExp("2001:1608:10:25::9249:d69b", "[0-9]{0,4}+\:[0-9]{0,4}+\:[0-9]{0,4}+\:[0-9]{0,4}", 0)
Local $aISITIPv6b = StringRegExp("2a0d:2a00:1::", "[0-9]{0,4}+\:[0-9]{0,4}+\:[0-9]{0,4}+\:[0-9]{0,4}", 0)
Local $aISITIPv4 = StringRegExp("192.168.0.1", "[0-9]{0,4}+\:[0-9]{0,4}+\:[0-9]{0,4}+\:[0-9]{0,4}", 0)
ConsoleWrite("Sting1 = " & $aISITIPv6a & @CRLF)
ConsoleWrite("Sting2 = " & $aISITIPv6b & @CRLF)
ConsoleWrite("Sting3 = " & $aISITIPv4 & @CRLF) ; Should Fail

 

Edited by Dwalfware

Share this post


Link to post
Share on other sites

Ok found the solution

https://www.autoitscript.com/forum/topic/144168-validate-ipv6-address/

#include <StringConstants.au3>
Local $aISITIPv6a = StringRegExp("2001:1608:10:25::9249:d69b", "^(?i)([\da-f]{1,4}|::)((:{0,2}[\da-f]{0,4}){0,7})$", 0)
Local $aISITIPv6b = StringRegExp("2a0d:2a00:1::", "^(?i)([\da-f]{1,4}|::)((:{0,2}[\da-f]{0,4}){0,7})$", 0)
Local $aISITIPv4 = StringRegExp("192.168.0.1", "^(?i)([\da-f]{1,4}|::)((:{0,2}[\da-f]{0,4}){0,7})$", 0)
; Dany Sting = ^(?i)([\da-f]{1,4}|::)((:{0,2}[\da-f]{0,4}){0,7})$
ConsoleWrite("Sting1 = " & $aISITIPv6a & @CRLF)
ConsoleWrite("Sting2 = " & $aISITIPv6b & @CRLF)
ConsoleWrite("Sting3 = " & $aISITIPv4 & @CRLF) ; Should Fail

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • By Dwalfware
      HI
      Another head scratched
      Anyone solve how to get the IPV6 from WMI?
      I followed the usual SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionID='" & GUICtrlRead($cboAdapters) & "'
      get the index 
      port it to 
      Local $query = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & _GetSelectedNIC(), "WQL", 0x30 )
      All i can see is IPv4 addresses
      My question is is there another place the IPv6 information is hiding? I configured my LAN with IPV6 and my wireless with IPv4 so I can see what shows.
      Thanks in Advance.
      PS. I did try google
       
    • By jacQues
      Quick question for something I cannot test.
       
      My ISP is considering moving from IPv4 to IPv6.
      Does the function InetGet() work properly with IPv6?
      If not, what can I do? Use TCP*() functions instead?
       
      jacQues
       
      P.S.  Could this site maybe consider Bitcoin for donations?
    • By James
      Quick function for validating IPV6. It's not advanced, but can validate several notations.


      ; Default example If _ISIPV6IP('3ffe:1900:4545:3:200:f8ff:fe21:67cf') Then MsgBox(0, '', 'Valid IPV6 address!') ; Leading zeroes If _ISIPV6IP('2001:db8:85a3:0:0:8a2e:370:7334') Then MsgBox(0, '', 'Valid IPV6 address!') ; Groups of zeroes If _ISIPV6IP('2001:db8:85a3::8a2e:370:7334') Then MsgBox(0, '', 'Valid IPV6 address!') Func _ISIPV6IP($Addr) Return StringRegExp($Addr, "(([\da-f]{0,4}:{0,2}){1,8})") EndFunc
×
×
  • Create New...