40 lines
1.2 KiB
Text
40 lines
1.2 KiB
Text
|
;********************************
|
||
|
;*
|
||
|
;* lweb_IP.pbi
|
||
|
;*
|
||
|
|
||
|
|
||
|
Procedure IsIPStringValid(Adress.s)
|
||
|
Static My_Regex_v4
|
||
|
Static My_Regex_v6_nocompress
|
||
|
Static My_Regex_v6_compress
|
||
|
Static Valid = 0
|
||
|
|
||
|
My_Regex_v4 = CreateRegularExpression(#PB_Any, "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$")
|
||
|
My_Regex_v6_nocompress = CreateRegularExpression(#PB_Any, "^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$")
|
||
|
My_Regex_v6_compress = CreateRegularExpression(#PB_Any, "^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)::(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$")
|
||
|
|
||
|
If MatchRegularExpression(My_Regex_v4, Adress) And Valid = 0
|
||
|
Debug "My_Regex_v4"
|
||
|
Valid = 1
|
||
|
EndIf
|
||
|
If MatchRegularExpression(My_Regex_v6_nocompress, Adress) And Valid = 0
|
||
|
Debug "My_Regex_v6_nocompress"
|
||
|
Valid = 1
|
||
|
EndIf
|
||
|
If MatchRegularExpression(My_Regex_v6_compress, Adress) And Valid = 0
|
||
|
Debug "My_Regex_v6_compress"
|
||
|
Valid = 1
|
||
|
EndIf
|
||
|
|
||
|
FreeRegularExpression(My_Regex_v4)
|
||
|
FreeRegularExpression(My_Regex_v6_nocompress)
|
||
|
FreeRegularExpression(My_Regex_v6_compress)
|
||
|
|
||
|
If Valid = 1
|
||
|
ProcedureReturn #True
|
||
|
Else
|
||
|
ProcedureReturn #False
|
||
|
EndIf
|
||
|
|
||
|
EndProcedure
|