Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- while (sc.hasNext()){
- String eingabe = sc.nextLine();
- String newengabe = eingabe.toLowerCase();
- String [] array = newengabe.split(" ");
- if (array[0].equals(array[1])){
- System.out.println("richtig");
- }else
- for (int i = 0; i<array[0].length();i++){
- String regex = "^"+array[0].substring(0,i) + ".?("+array[0].substring(i);// ar.sub выводит от i и до конца
- if (i<array[0].length()-1){
- regex = regex + "|"+array[0].substring(i+1);
- }
- regex = regex +"$)";
- if (array[1].matches(regex)){
- System.out.println("ok");
- }//else if (!array[0].equals(array[1])&&!array[1].matches(regex)){
- // System.out.println(false);
- //}
- }
- }
Add Comment
Please, Sign In to add comment