Guest User

Untitled

a guest
Jun 24th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. public static void main(String[] args) {
  2. Scanner sc = new Scanner(System.in);
  3. while (sc.hasNext()){
  4. String eingabe = sc.nextLine();
  5. String newengabe = eingabe.toLowerCase();
  6. String [] array = newengabe.split(" ");
  7. if (array[0].equals(array[1])){
  8. System.out.println("richtig");
  9. }else
  10.  
  11. for (int i = 0; i<array[0].length();i++){
  12. String regex = "^"+array[0].substring(0,i) + ".?("+array[0].substring(i);// ar.sub выводит от i и до конца
  13. if (i<array[0].length()-1){
  14. regex = regex + "|"+array[0].substring(i+1);
  15.  
  16. }
  17. regex = regex +"$)";
  18. if (array[1].matches(regex)){
  19. System.out.println("ok");
  20.  
  21.  
  22.  
  23.  
  24.  
  25. }//else if (!array[0].equals(array[1])&&!array[1].matches(regex)){
  26. // System.out.println(false);
  27. //}
  28.  
  29. }
  30.  
  31.  
  32.  
  33. }
Add Comment
Please, Sign In to add comment