本帖提供一个将ip分段成4段提取的范例
本帖提供一个将ip分段成4段提取的范例,方法比较笨拙(若哪位有更佳方法,可随帖)。案例仅仅是一个思路,会用的人可以在实际应用中去修改使用。:local ip1.22.333.4444/32
:local section1
:local section2
:local section3
:local section4
:local length
:local length1
:local length2
:local length3
:local length4
:set ip [:pick $ip 0 [:find$ip "/"]]
:set length [:len $ip]
:log warn $ip
########section1#########
:set section1 [:pick $ip 0 [:find$ip "."]]
:set length1[:len $section1]
:log warn ("ip_section1 is: " . $section1 . " length is: " . $length1)
########section2#########
:set section2 [:pick $ip ($length1+1) $length]
:set section2 [:pick $section2 0 [:find$section2 "."]]
:set length2[:len $section2]
:log warn ("ip_section2 is: " . $section2 . " length is: " . $length2)
########section3#########
:set section3 [:pick $ip ($length1+1+$length2+1) $length]
:set section3 [:pick $section3 0 [:find$section3 "."]]
:set length3[:len $section3]
:log warn ("ip_section3 is: " . $section3 . " length is: " . $length3)
########section4#########
:set section4 [:pick $ip ($length1+1+$length2+1+$length3+1) $length]
:set length4[:len $section4]
:log warn ("ip_section4 is: " . $section4 . " length is: " . $length4) 我也是这个办法,根据点位提取各段ip值
:)
不过楼主比我写的脚本更规范{:3_53:} 谢谢山东兄弟sealin ,从你那里购买的你的dell服务器,我还在用呢,你最近新增什么高配置的硬件了??
页:
[1]