This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can i validate the ip address

 
ajay verma
Ranch Hand
Posts: 37
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how can i validate the ip address.example are given below

10.02.0.99 is invalid
1.2.3.4.5.6 is invalid
109.2.8.06 is invaid

hint: with the help of String tokenize()
 
Rob Spoor
Sheriff
Pie
Posts: 20368
43
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, 10.02.0.99 and 109.2.8.06 are perfectly valid. Just because they have an extra 0 doesn't mean they aren't valid. 109.2.8.06 is equal to 109.2.8.6.

Second, use String.split instead, using "\\." as the regex. The \\ will be resolved to a single \ for the regex, which is used to escape the .
 
Bill Shirley
Ranch Hand
Posts: 457
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
give it a try,
if you need help, let us know,
post the code,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic