小问题,给分100,在线等待 indexOf("select")>0 && indexOf("from")>0 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 sorry 写错了var str = "select * from customer";if (str.indexOf("select")>0 && str.indexOf("from")>0) alert("is ok"); <script>alert(/select.+from/.test("select * from customer"))</script> var sSource = "select * from customer";if (sSource.indexOf("select")!=-1 && sSource.indexOf("from")!=-1) alert ("ok");注意:indexOf中O要大写 <SCRIPT LANGUAGE=javascript><!--str="SELECT * from tablename";str=str.toLowerCase();var re=/select.+from.+/g;alert(re.test(str))//--></SCRIPT> str="SELECT * from tablename";str=str.toLowerCase();re1=/select/gi;if(re1.test(str)==false)alert("'select'不存在");re2=/from/gi;if(re2.test(str)==false)alert("'from'不存在");re3=/select.+from/gi;if(re3.test(str)==false)alert("'select和from'都不存在");小改楼上的。:)你可以将字符串改掉试试。 注:str=str.toLowerCase(); 是将字符串的字符变成小写 我也是刚知的。学到东西了。:)同理可得到 str.toUpperCase()是是将字符串的字符变成大写但如何将字符串的大小写转换呢???我试过这样str.toInvertCase() 不行啊!!!请教!!! "indexOf"方法是得到子字符串在父字符串中的起始位置,从0开始计所以gzh_seagull(不可)的方法是错的,要var str = "select * from customer";if (str.indexOf("select")>=0 && str.indexOf("from")>=0) alert("is ok");才对bencalie(Bencalie) 是对的 jquery如何完成上传图片的剪切 js 日期问题 ajax未定义 求一个弹出可拖动页面! javascript传值问题???? insertAdjacentHTML一个DIV后,怎么调用这个DIV无效? 求一个JSP的树型菜单 关于activex的调用,急救 怎么捕捉事件? js判断input输入框 菜鸟问题,请帮忙! 这是ie的BUG吗?
var str = "select * from customer";
if (str.indexOf("select")>0 && str.indexOf("from")>0)
alert("is ok");
alert(/select.+from/.test("select * from customer"))
</script>
if (sSource.indexOf("select")!=-1 && sSource.indexOf("from")!=-1)
alert ("ok");
注意:indexOf中O要大写
<!--
str="SELECT * from tablename";
str=str.toLowerCase();
var re=/select.+from.+/g;
alert(re.test(str))
//-->
</SCRIPT>
str=str.toLowerCase();re1=/select/gi;
if(re1.test(str)==false)alert("'select'不存在");
re2=/from/gi;
if(re2.test(str)==false)alert("'from'不存在");
re3=/select.+from/gi;
if(re3.test(str)==false)alert("'select和from'都不存在");小改楼上的。:)你可以将字符串改掉试试。
我也是刚知的。学到东西了。:)
同理可得到 str.toUpperCase()是是将字符串的字符变成大写但如何将字符串的大小写转换呢???
我试过这样str.toInvertCase() 不行啊!!!请教!!!
所以gzh_seagull(不可)的方法是错的,
要
var str = "select * from customer";
if (str.indexOf("select")>=0 && str.indexOf("from")>=0)
alert("is ok");
才对bencalie(Bencalie) 是对的