这个用正则表达式有点浪费吧,用javascript也可以做到var mystring = "****" // 你的字符串
var flag = mystring.indexOf("apple") // 如果有则 flag >0
if (flag>0)
  document.writeln("有");
else
  document.writeln("没有");

解决方案 »

  1.   

    superszhu(精彩世界),不行啊,也是为真值的
      

  2.   

    reverse the test condition, for examplevar s = "sssappleddd";
    var re = /apple/i;
    if (!re.test(s))
     alert("no apple");
    else
     alert("has apple");
      

  3.   

    大哥,用它的返回值,

    function testStr(str) {
      if ((/\apple+/i).test(str)) {
        alert("有apple");
      } else {
        alert("没有apple");
      }
    }
      

  4.   

    大哥,我是用来替换内容的,我主要是想查找成对的标记,像ab替换成<b>ab</b>,a替换成<a href='a'>a</a>
      

  5.   

    look into the negative lookahead:
    (?!pattern)
      

  6.   

    (?!pattern)?
    我这样写/(?!apple)/g也不行哦
      

  7.   

    http://www.csdn.net/expert/Topicview1.asp?id=861190