Advertisement
Steelsouls

Java Regex Issues

Mar 12th, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. Scanner sc = new Scanner(System.in);
  2.  
  3.     static String getMenuInput(String scannerPattern) {
  4.         String input = null;
  5.         while (input == null) {
  6.             input = sc.findInLine(scannerPattern);
  7.             sc.nextLine();
  8.         }
  9.         return input;
  10.     }
  11.  
  12. String menuInput;
  13. menuInput = getMenuInput("B|R|Q"); // This works, returns value that can be used to navigate menu
  14. menuInput = getMenuInput("0-9"); // This gets stuck in the loop (apparently not able to find pattern)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement