Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how can i validate the ip address

 
ajay verma
Ranch Hand
Posts: 37
  • 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: 20667
65
Chrome Eclipse IDE Java Windows
  • 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
  • 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