title: Check string for valid input in java using regex
body: <p>I'm currently working on an assignment where I need to validate some user input from a form(JSP and servlets). I use regex to check if i.e., phone number only contains integers. I want to do the same with name and surname, but I have some trouble understanding regex.    </p>
  
  <p>Allowed characters for "name" are letters, space and dash</p>
  
  <p>My check for phonenumber which works:</p>
  
  <pre><code>else if(!number.matches("[0-9]+")){
  
                  return false;
  }
  </code></pre>
  
  <p>Allowed characters for "surname" are letters and dash ( not space )
  So what I need help with is the expression for the names. </p>