I am trying to understand working of regex matching in java and have a doubt in the followeing code snippet
When i run it :http://ideone.com/2vIK77
/* 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);
}
}
it says false on first and true on second .
1) false
matches2 = true
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