title: Regex test whether string contains digits
body: <p>I wanted to test if a string contains numbers (at least one number)
  so I tried out this:</p>
  
  <pre><code>public class Test {
  private static final String DIGIT_PATTERN = "^(?=.*\\d)";
  private static final Pattern DIGIT_PATTERN_COMPILED = Pattern.compile(DIGIT_PATTERN);
  
  /**
   * 
   * @param args
   */
  public static void main(String[] args) {
      String passwordOne = "123";
      String passwordTwo = "abc";
  
      Matcher matcher = null;
  
      matcher = DIGIT_PATTERN_COMPILED.matcher(passwordOne);
  
      if(!matcher.matches()) {
          System.out.println("Password " + passwordOne + " contains no number");
      } else {
          System.out.println("Password " + passwordOne + " contains number");
      }
  
      matcher = DIGIT_PATTERN_COMPILED.matcher(passwordTwo);
  
      if(!matcher.matches()) {
          System.out.println("Password " + passwordTwo + " contains no number");
      } else {
          System.out.println("Password " + passwordTwo + " contains number");
      }   
  }
  }
  </code></pre>
  
  <p>Unfortunately both if clauses print out that it contains no number.
  Am I using the regex wrong?</p>