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.
我正在尝试编写一个lex模式,它将允许我使用CIDR表示法识别包括IPV6地址在内的IPV6地址。我使用的模式如下所示。
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
IPV6ADDRESS_CIDR的正则表达式没有按预期工作。我测试
2001:1234::5678:5:6:7:8/64
It doesn't seem to recognize it properly.Am I making some mistake here?
它似乎不能正确地识别它。我在这里犯了什么错误吗?
1 个解决方案
#1
0
I have managed to get the regular expression for IPV6 address as follows.
我已经设法得到了如下所示的IPV6地址的正则表达式。
IPV6ADDRESS_CIDR [ \t]{IPV6ADDRESS}(/(1[01][0-9]|12[0-8]|[0-9]{1,2}))[ \t]
IPV6ADDRESS_CIDR \[t]{ IPV6ADDRESS }(/(1[1][0 - 9]| 12(主)|[0 - 9]{ 1,2 }))\[t]
I have tested the above and it is working.thanks.
我已经测试过了,它是有效的,谢谢。
#1
0
I have managed to get the regular expression for IPV6 address as follows.
我已经设法得到了如下所示的IPV6地址的正则表达式。
IPV6ADDRESS_CIDR [ \t]{IPV6ADDRESS}(/(1[01][0-9]|12[0-8]|[0-9]{1,2}))[ \t]
IPV6ADDRESS_CIDR \[t]{ IPV6ADDRESS }(/(1[1][0 - 9]| 12(主)|[0 - 9]{ 1,2 }))\[t]
I have tested the above and it is working.thanks.
我已经测试过了,它是有效的,谢谢。