title: Java string matching with wildcards
body: <p>I have a pattern string with a wild card say X (E.g.: abc*).</p>
  
  <p>Also I have a set of strings which I have to match against the given pattern.</p>
  
  <p>E.g.: </p>
  
  <p>abf - false</p>
  
  <p>abc_fgh - true</p>
  
  <p>abcgafa - true</p>
  
  <p>fgabcafa - false</p>
  
  <p>I tried using regex for the same, it didn't work.</p>
  
  <p>Here is my code</p>
  
  <pre><code>String pattern = "abc*";
  String str = "abcdef";
  
  Pattern regex = Pattern.compile(pattern);
  
  return regex.matcher(str).matches();
  </code></pre>
  
  <p>This returns false</p>
  
  <p>Is there any other way to make this work?</p>
  
  <p>Thanks</p>