js中:
varCts = "aaddssyes";
if(Cts.indexOf("yes") > 0 ){
alert('Cts中包含Text字符串');
}
找的是最開始的位置,如果沒找到,則返回的是-1.
functionIndexDemo(str){
varstr1 = "BABEBIBOBUBABEBIBOBU"
vars = str1.indexOf(str);
return(s);
}
str是外邊傳來的一個字符串
java中:
public static void main(String[] args) {
String str="ABC_001";
if(str.indexOf("ABC")!=-1){
System.out.println("包含");
}else{ System.out.println("不包含");
}
}
