CreateTime--2017年2月28日09:37:06Author:Marydonjs判断是否包含指定字符串
var inputValue = "thunder://piaohua.com"
;
//方法一:使用indexOf()方法实现
if (inputValue.indexOf("thunder://") >= 0
) {
alert(1
);
}
//自定义javascript的startWith()和endWith()方法
String.prototype.startWith=
function(str){
var reg=
new RegExp("^" +
str);
return reg.test(
this);
}
String.prototype.endWith=
function(str){
var reg=
new RegExp(str+"$"
);
return reg.test(
this);
}
//实现
if (inputValue.startWith("thunder://"
)) {
alert(1
);
}
转载于:https://www.cnblogs.com/Marydon20170307/p/6649505.html