id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

isValidIp


Use the following definition of an IP address:

IP address is a string in the form "A.B.C.D", where A, B, C, and D are
integers ranging from 0 to 255 inclusive. Leading zeros are allowed.
The length of A, B, C, or D can't be greater than 3.

Here are some valid IP addresses:
000.12.12.034
121.234.12.12
23.45.12.56

Here are some invalid IP address:

000.12.234.23.23
666.666.23.23
.213.123.23.32
23.45.22.32.
I.Am.not.an.ip
Given a String containing any combination of characters, determine whether the string is a valid IP.

Note: The Character class has a static method isDigit(char c) that returns true if c is a digit and false otherwise.

isValidIp("000.12.12.034") → true
isValidIp("000.12.234.23.23") → false
isValidIp("121.234.12.12") → true

...Save, Compile, Run (ctrl-enter)

public boolean isValidIp(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Copyright Nick Parlante 2017 - privacy