Question

I am trying to write a lex pattern that will allow me to recognize IPV6 addresses including IPV6 addresses with CIDR notation.The pattern that I use is given below.

IPV4ADDRESS_CIDR [ \t]*(((2(5[0-5]|[0-4][0-9])|[01]?[0-9][0-9]?)\.){3}(2(5[0-5]|[0-4][0-9])|[01]?[0-9][0-9]?)(\/(3[012]|[12]?[0-9])))[ \t]*
IPV4ADDRESS      [ \t]*(([[:digit:]]{1,3}"."){3}([[:digit:]]{1,3}))[ \t]*
hex4             ([[:xdigit:]]{1,4})
hexseq           ({hex4}(:{hex4})*)
hexpart          ({hexseq}|({hexseq}::({hexseq}?))|::{hexseq})
IPV6ADDRESS      [ \t]*({hexpart}(":"{IPV4ADDRESS})?)[ \t]*
IPV6ADDRESS_CIDR [ \t]*(IPV6ADDRESS)(\/(1[01][0-9]|12[0-8]|[0-9]{1,2}))[ \t]*

The regular expression for IPV6ADDRESS_CIDR is not working as expected.I am testing with

2001:1234::5678:5:6:7:8/64 

It doesn't seem to recognize it properly.Am I making some mistake here?

Was it helpful?

Solution

I have managed to get the regular expression for IPV6 address as follows.

IPV6ADDRESS_CIDR [ \t]{IPV6ADDRESS}(/(1[01][0-9]|12[0-8]|[0-9]{1,2}))[ \t]

I have tested the above and it is working.thanks.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top