Advertisement
apl-mhd

Java LocalClass RegularExpression

Dec 9th, 2017
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1. package localClass;
  2. import java.lang.*;
  3.  
  4. //import com.sun.org.apache.xpath.internal.operations.String;
  5.  
  6. public class LocalClassExample {
  7.  
  8.     String a;
  9.  
  10.   static   java.lang.String regular= "[^0-9]";
  11.  
  12.    static void validet(java.lang.String ... arg ){
  13.  
  14.  
  15.         class PhoneNumber{
  16.  
  17.  
  18.         java.lang.String numbervalid = null;
  19.             public PhoneNumber(java.lang.String number) {
  20.                  number = number.replaceAll(regular,"");
  21.  
  22.                  if(number.length() == 11)
  23.                      numbervalid = number;
  24.  
  25.             }
  26.  
  27.  
  28.         }
  29.  
  30.  
  31.         for(String n:arg){
  32.  
  33.  
  34.             PhoneNumber ob = new PhoneNumber(n);
  35.  
  36.             if(ob.numbervalid!=null)
  37.                 System.out.println("valid number :"+ob.numbervalid);
  38.             else
  39.                 System.out.println("not valid");
  40.  
  41.  
  42.         }
  43.  
  44.     }
  45.  
  46.  
  47.     public static void main(String[] args) {
  48.  
  49.        //LocalClassExample ob = new LocalClassExample();
  50.  
  51.        validet("384u3889","01710-453438");
  52.  
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement