Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.02 KB | None | 0 0
  1.  public static void main(String[] args){
  2.         expect("Fobbar", clean("3.4 Fobbar")  );
  3.         expect("Fob4bar", clean("3.4 Fob4bar")  );
  4.         expect("Fob4bar", clean(" 3.4 Fob4bar")  );
  5.         expect("Fob4bar", clean(" 3.4   Fob4bar")  );
  6.         expect("A   Fob4bar", clean(" 3.A   Fob4bar")  );
  7.         expect("Fob4bar", clean(" 3   Fob4bar")  );
  8.         expect("foobar 3.4 Fobbar", clean("foobar 3.4 Fobbar")  );
  9.         expect("foobar 3.4 Fobbar", clean("     foobar 3.4 Fobbar")  );
  10.         expect("Fobbar a3sdf ", clean(" 3.4    Fobbar a3sdf ")  );
  11.         expect("Fobbar a3sdf ", clean(" 3.4    Fobbar a3sdf ")  );
  12.        
  13.     }
  14.  
  15.     public static String clean(String stringToClean){
  16.       return stringToClean.replaceFirst("^\\s*[\\d\\.]*\\s*", "") ;
  17.     }
  18.  
  19.     public static void expect(String expected, String actual ){
  20.         if (expected.equals(actual))
  21.             System.out.println("ok");
  22.         else
  23.             System.out.println("False. Expeced : " +expected + " but got "+ actual);
  24.  
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement