实现boolean isSubstring(String s, String p). 如果p是s的substring,就返回true。 p可以是带有'*'的,一个'*'可以代表0或者多个任意字符
public static void main(String[] args) {
System.out.println(isSubStr("abcde", "bcd"));
System.out.println(isSubStr("abcde", "b*d"));
System.out.println(isSubStr("abcde", "b*f"));
System.out.println(isSubStr("abcde", "b*"));
}
static boolean isSubStr(String s, String p){
String strInP;
int i =0;
for(; i<p.length(); i++){
if(p.charAt(i)=='*')
break;
}
strInP = p.substring(0, i);
int foundIndex = s.indexOf(strInP);
if(foundIndex==-1)
return false;
return i>=p.length()||isSubStr(s.substring(foundIndex+strInP.length()), p.substring(i+1));
}