title: java regex sometimes fails to match
body: <p>I am trying to understand working of regex matching in java and have a doubt in the followeing code snippet </p>
  
  <p>When i run it :<a href="http://ideone.com/2vIK77" rel="nofollow">http://ideone.com/2vIK77</a></p>
  
  <pre><code>/* package whatever; // don't place package name! */
  
  import java.util.*;
  import java.lang.*;
  import java.io.*;
  import java.util.regex.*;
  
  /* Name of the class has to be "Main" only if the class is public. */
  class Ideone
  {
      public static void main (String[] args) throws java.lang.Exception
      {
  
  
           String a = "Basic";
           String b = "Bas*";
  
           boolean matches = Pattern.matches(b, a); 
           System.out.println("1) "+matches);
  
  
          String text2    =
          "This is the text to be searched " +
          "for occurrences of the pattern.";
  
          String pattern2 = ".*is.*";
  
          boolean matches2 = Pattern.matches(pattern2, text2);
  
          System.out.println("matches2 = " + matches2);
  
  
      }
  }
  </code></pre>
  
  <p>it says 
  false on first and true on second . </p>
  
  <pre><code>1) false
  matches2 = true
  </code></pre>
  
  <p>I am not able to understand why am i getting false in first case .. I expect it to be true  . 
  Can someone please suggest me something </p>