I need a regex pattern that validates IP addresses. It's easy enough for Google, but I have a little catch. I need the latest numbers to be able to accept the range. Thus, the next entry will be confirmed.
XXX.XXX.XXX.XY
so something like 168.68.2.1-34
I found patterns for regular IPs, but not for range processing.
To accept a number from 0 to 255, I would use (25[0-5]|2[0-4]\d|[0-1]?\d{1,2}). Calling the above expression A, Regex for the IP range will look like
(25[0-5]|2[0-4]\d|[0-1]?\d{1,2})
A\.A\.A\.A-A
or
(A\.){3}A-A
If a range is optional, use (-A)?instead -A.
(-A)?
-A
, , , Regex .
, :
(normal-ip-regex)-[0-9]+
- , , (, , "X" , "Y", ).
"" IP- . , - , .
, , - inet_aton ( ).
inet_aton
Once you have the address as an integer, you can verify that it is within the valid range, just as you check any other integer (<and> most likely).
Source: https://habr.com/ru/post/1751138/More articles:How to write COM EXE for Win32 using Tcl and TclApp? - perlWhat does it mean () => mean (C # 3.0) - c # -3.0If I add content to the page via JavaScript, it will be crawled using a search engine - javascriptHow to raise an event in C # - Best approach - c #how much memory is needed for metadata when using the new int [10]? - c ++Как узнать, когда пользователь перенаправляет вывод из оболочки erlang в файл - erlangASP.NET MVC AntiForgeryToken бросает свое исключение в GET? - asp.net-mvchttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1751141/javascript-will-not-pass-focus-to-element&usg=ALkJrhiRubnNKxsIVNOZ78Bq7lle11wvGACollision detecting a custom outline form represented as a list of points - c #+ \ operator in Python - operatorsAll Articles