Recent Posts

Sunday 7 June 2015

Validating IPAddress in Java

This is the part of the java Regular Expressions, Validating,searching the data using the matches function This is mostly used in analyzing the data. To know further about it read about JAVA Regex  

import java.io.*;

public class ValidIP{

     public static void main(String []args){
       String IP="000.12.12.034";
       String pat="(([01]?(\\d)?(\\d))|([2]?([012345])?([012345])))";
       String pattern=pat+"."+pat+"."+pat+"."+pat;
       System.out.println(IP.matches(pattern));
     }
}

Smart Siva

Author & Editor

In Life every second is important, In programming every line of code is important.

0 comments:

Post a Comment

 
biz.