February 2019
Intermediate to advanced
626 pages
15h 51m
English
Validating an IPv4 address using a regular expression is not necessarily a trivial task.
The IP address consists of four octets; each octet can be a value between 0 and 255. When using a regular expression, the values are considered strings, therefore, the following strings must be considered:
Each of these is an exclusive set, so alternation is used to merge all of the previous small expressions into a single expression. This generates the following group, that matches a single octet (0 to 255):
([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]) ...Read now
Unlock full access