Problem 57805. Easy Sequences 105: One-line Code Challenge - IPv4 Address Validation

The Internet Protocol version 4 (IPv4) is the dominant protocol for routing devices over the internet. IPv4 addresses are usually represented by four 1-byte decimal numbers (0 to 255) separated by three dots.
In this exercise, we are asked to check whether a given string of characters is a valid IPv4 address or not. Leading zeros are allowed, however each byte should only contain at most 3 characters, with no spaces.
For example, the following are valid IPv4 address:
But the following are invalid addresses:
'123. 23.123.123'
'i like matlab'
The following restrictions apply:
  • The function should only have one (1) line of code, excluding the function start line.
  • Semicolons (;) are considered end-of-line characters.
  • Please suppress the function end line. Keyword 'end' is not allowed.
  • Regular expressions are allowed.
  • Only 'pure' matlab functions/commands are allowed (no java, no python).
This would be the last of my one-line challenges.

Solution Stats

26.67% Correct | 73.33% Incorrect
Last Solution submitted on Apr 06, 2023

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers4

Suggested Problems

More from this Author116

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!