Malkey Posted November 2, 2014 Posted November 2, 2014 I ran your script but I see no regex being pumped out of it. You are correct. My script of post #39 does not use a regex to check if an Ip address is within a CIDR address. The line, "Return ($IpNum >= $LowIp And ($IpNum <= $UpIp)) ? 1 : 0" is used to check if an Ip address is within a CIDR address. I originally used the following regex method. But I thought the bit functions method of post #39 was easier and simpler. ; From Post #13 ; "^64\.237\.(3[2-9]|[45][0-9]|6[0-3])\.[0-9]+$" ; 64.237 .(32-39 |40-59 |60-63) .(0-infinity) ; Create RE Pattern to match IPs in the range of 192.168.12.1 - 192.168.15.254 Local $REPattern = "192\.168\." & _RERange(12, 15) & "\." & _RERange(1, 254) ConsoleWrite($REPattern & @LF) $sChckIP1 = "192.168.12.1" ConsoleWrite(StringRegExp($sChckIP1, $REPattern) & @LF) ; Returns "1" for True (ChckIp is within range of Ip's). $sChckIP2 = "192.168.12.0" ConsoleWrite(StringRegExp($sChckIP2, $REPattern) & @LF) ; Returns "0" for Fakse (ChckIp is not within range of Ip's). Func _RERange($iLowerLimit, $iUpperLimit) Local $Ret = "(" For $i = $iLowerLimit To $iUpperLimit $Ret &= $i & "|" Next Return StringTrimRight($Ret, 1) & ")" EndFunc ;==>_RERange
Morthawt Posted November 2, 2014 Author Posted November 2, 2014 You are correct. My script of post #39 does not use a regex to check if an Ip address is within a CIDR address. The line, "Return ($IpNum >= $LowIp And ($IpNum <= $UpIp)) ? 1 : 0" is used to check if an Ip address is within a CIDR address. I originally used the following regex method. But I thought the bit functions method of post #39 was easier and simpler. ; From Post #13 ; "^64\.237\.(3[2-9]|[45][0-9]|6[0-3])\.[0-9]+$" ; 64.237 .(32-39 |40-59 |60-63) .(0-infinity) ; Create RE Pattern to match IPs in the range of 192.168.12.1 - 192.168.15.254 Local $REPattern = "192\.168\." & _RERange(12, 15) & "\." & _RERange(1, 254) ConsoleWrite($REPattern & @LF) $sChckIP1 = "192.168.12.1" ConsoleWrite(StringRegExp($sChckIP1, $REPattern) & @LF) ; Returns "1" for True (ChckIp is within range of Ip's). $sChckIP2 = "192.168.12.0" ConsoleWrite(StringRegExp($sChckIP2, $REPattern) & @LF) ; Returns "0" for Fakse (ChckIp is not within range of Ip's). Func _RERange($iLowerLimit, $iUpperLimit) Local $Ret = "(" For $i = $iLowerLimit To $iUpperLimit $Ret &= $i & "|" Next Return StringTrimRight($Ret, 1) & ")" EndFunc ;==>_RERange I am not sure if you realise what this program is for. It is to generate regex patterns for use in another software product called TeamSpeak that can take regex IP bans. I am not doing any checks, tests or anything in AutoIt. I am using AutoIt to generate regex patterns, thats it. Free and easy Autoit scripting video tutorials (plus more videos always coming!) General video tutorials, especially correct and safe TeamSpeak permissions tutorials.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now