title: phone Number validation in java
body: <p>I want to validate a phone number in such Way :-</p>
  
  <p>The field should allow the user to enter characters and should auto-correct. So an entry of "+1-908-528-5656" would not create an error for the user, it would just change to "19085285656".</p>
  
  <p>I also want to number range between 9 to 11.</p>
  
  <p>I also tried with the below code but not concluded to the final solution:</p>
  
  <pre><code> final String PHONE_REGEX = "^\\+([0-9\\-]?){9,11}[0-9]$";
   final Pattern pattern = Pattern.compile(PHONE_REGEX);
   String phone = "+1-908-528-5656";      
   phone=phone.replaceAll("[\\-\\+]", "");
   System.out.println(phone);
   final Matcher matcher = pattern.matcher(phone);
   System.out.println(matcher.matches()); 
  </code></pre>