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));
}
}
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));
}
}
0 comments:
Post a Comment