1.不清楚你要匹配什么
2.不包含sdn
/[^(sdn)]+/

解决方案 »

  1.   


    比如有这么一段文字
    aaa bbb ccc "FF's fullname is \"firefox\"" ddd用正则,把红色部分弄出来
      

  2.   

    这样只能匹配不是(,s,d,n,)的字符,如say hello的s
      

  3.   


    谢谢,怪我没说清楚,其实我要匹配的是,完全符合JS字符串标准的一个字符串,包括引号
    你这个在只一个字符合的时候是正确的,如果多个就不成了,如:
    aaa bbb ccc "FF's fullname is \"firefox\"" ddd "hello"
      

  4.   

    "hello"
    "FF's fullname is \"firefox\"" 
    都匹配啊
    还是不知道lz 要匹配什么
     
      

  5.   

    就是上面红色字的部分
    \".*\" 
    匹配成"FF's fullname is \"firefox\"" ddd "hello"了
      

  6.   

    谢谢热心的bhtfg538,不过还是不行
    匹配到的是
    "FF's fullname is \"

    "" ddd "
      

  7.   

    谢谢了,我自己改了一下,把可能的转义放进去了"(([^\\]*)(\\["rn\\t])*)*?"
      

  8.   

    接分...
    早就能冲星了
    好几个月没上csdn了
      

  9.   

    <script type="text/javascript">
    function TextLine(DaString, DaSearch){
    var Result = -1;
    (DaString + "\n").replace(
    RegExp("(^|\\n).*?" + DaSearch + ".*?($|\\n)", "i"),
    function(){
    if ( Result == -1 ) {
    Result = arguments[3] + arguments[0].length
    }
    },
    ""
    )
    return (
    (DaString + "\n").substring(0, Result).match(/\n/g) || {length:-1}
    ).length
    }
    alert(
    TextLine("hello csdn\nhello msdn\nhello msn", "m1sn")
    )
    alert(
    TextLine("hello csdn\nhello msdn\nhello msn", "msn")
    )
    </script>题目理解错误,以上代码是返回行号,但是已经不想改了,楼主稍微改改就可以用了。