Validate an IP address

Write a solution to validate an IPv4 address.

IPv4 addresses are canonically represented in dot-decimal notation, which consists of four decimal numbers, each ranging from 0 to 255, separated by dots, e.g.,

For valid IPv4 addresses return true and for invalid addresses return false.

Example Solution

Below are some valid IPv4 addresses:,,

Below are some invalid IPv4 addresses:,, 10.15.10

Contributed by Murat Sütunç