求正则式 1.不清楚你要匹配什么2.不包含sdn/[^(sdn)]+/ 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 比如有这么一段文字aaa bbb ccc "FF's fullname is \"firefox\"" ddd用正则,把红色部分弄出来 这样只能匹配不是(,s,d,n,)的字符,如say hello的s 谢谢,怪我没说清楚,其实我要匹配的是,完全符合JS字符串标准的一个字符串,包括引号你这个在只一个字符合的时候是正确的,如果多个就不成了,如:aaa bbb ccc "FF's fullname is \"firefox\"" ddd "hello" "hello""FF's fullname is \"firefox\"" 都匹配啊还是不知道lz 要匹配什么 就是上面红色字的部分\".*\" 匹配成"FF's fullname is \"firefox\"" ddd "hello"了 谢谢热心的bhtfg538,不过还是不行匹配到的是"FF's fullname is \"和"" ddd " 谢谢了,我自己改了一下,把可能的转义放进去了"(([^\\]*)(\\["rn\\t])*)*?" 接分...早就能冲星了好几个月没上csdn了 <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>题目理解错误,以上代码是返回行号,但是已经不想改了,楼主稍微改改就可以用了。 两个tomcat发布两个工程,window.showModalDialog不能传值和获取返回值 在线等,怎么在window.open中调js方法 帮忙写个正则表达式 javascript操作cookie 新手提问JS 模态窗口使用时的问题 如何才能控制让客户浏览的页面内容禁止被COPY和打印? MAVEN打包压缩JS CSS的问题 如何解决使窗口最大化自动关闭的浏览器版本问题? 用JavaScript咋写,急急急!!! 子窗口向父窗口写数据,而不是返加数据. 弹出层问T:给层赋值、鼠标离开时关闭,,,,,,,,,,
比如有这么一段文字
aaa bbb ccc "FF's fullname is \"firefox\"" ddd用正则,把红色部分弄出来
谢谢,怪我没说清楚,其实我要匹配的是,完全符合JS字符串标准的一个字符串,包括引号
你这个在只一个字符合的时候是正确的,如果多个就不成了,如:
aaa bbb ccc "FF's fullname is \"firefox\"" ddd "hello"
"FF's fullname is \"firefox\""
都匹配啊
还是不知道lz 要匹配什么
\".*\"
匹配成"FF's fullname is \"firefox\"" ddd "hello"了
匹配到的是
"FF's fullname is \"
和
"" ddd "
早就能冲星了
好几个月没上csdn了
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>题目理解错误,以上代码是返回行号,但是已经不想改了,楼主稍微改改就可以用了。