title: Why is my program not waiting for input?
body: <p>I'm trying to get user input and validate it using regular expressions. However, when I run the program, it doesn't seem to be waiting to receive any additional user input. Instead, I'm getting </p>
  
  <blockquote>
    <p>Exception in thread "main" java.util.NoSuchElementException`</p>
  </blockquote>
  
  <p>Any help on what is happening would be great!</p>
  
  <p>Here is my code: </p>
  
  <pre><code>//Retrieve name
  System.out.println("What name would you like to search for? (Enter first name only without spaces)");
  Scanner input = new Scanner(System.in);
  while (!input.hasNext("[A-Za-z]+")) {
      System.out.println("Invalid entry. Please enter first name only.");
      input.next();
  }
  String name = input.next();
  System.out.println("You gave me as input the name:" + name);
  }
  </code></pre>