怎样修改一下这个正则表达式? 本帖最后由 cnforecast 于 2010-02-03 19:21:36 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 newwin.document.writeln("function addbr()"); newwin.document.writeln("{"); newwin.document.writeln("var str=document.getElementById(\'text\').value;"); newwin.document.writeln("str=str.replace(/(\\r\\n|$)/g,\"<br>$1\");"); newwin.document.writeln("document.getElementById(\'text\').value=str;"); newwin.document.writeln("}"); newwin.document.writeln(""); 楼主需要这样改:var x = [];x.push("function addbr()"); x.push("{"); x.push("var str=document.getElementById(\'text\').value;"); x.push("str=str.replace(\/\\r\\n\/gm,\"\\r\\n\\r\\n\");"); x.push("document.getElementById(\'text\').value=str;"); x.push("}"); x.push(""); newwin.document.writeln(x.join(" <br />")); 又研究了一下正则,通过二楼知道,原来空格直接打上就行了。所以经过多次尝试,只加两个符号就满足了要求newwin.document.writeln("function addbr()"); newwin.document.writeln("{"); newwin.document.writeln("var str=document.getElementById(\'text\').value;"); newwin.document.writeln("str=str.replace(\/\\r\\n\/gm,\"\\r\\n\ \\r\\n\");"); newwin.document.writeln("document.getElementById(\'text\').value=str;"); newwin.document.writeln("}"); newwin.document.writeln(""); 就是加了红色的,一个斜杠,然后打上个空格 关于以Json格式在html传值的问题 call()继承和原型继承有什么区别吗?? 怎样循环获取一个层中某个表格中的某行某列的值? 闭包? 改变图像的问题。 问reload()相关的问题 求可以在<textarea>里面插入表格,图片,设置字体颜色,大小的JS代码,高分送!! 脚本中无法读取注册表二进键值? 请问哪有javascript语句,函数用法的书下载,谢了,(80分), 请问如何屏蔽IE浏览器上面的文本编辑器 解释一个javascript代码片段 页面刷新的问题
newwin.document.writeln("{");
newwin.document.writeln("var str=document.getElementById(\'text\').value;");
newwin.document.writeln("str=str.replace(/(\\r\\n|$)/g,\"<br>$1\");");
newwin.document.writeln("document.getElementById(\'text\').value=str;");
newwin.document.writeln("}");
newwin.document.writeln("");
x.push("function addbr()");
x.push("{");
x.push("var str=document.getElementById(\'text\').value;");
x.push("str=str.replace(\/\\r\\n\/gm,\"\\r\\n\\r\\n\");");
x.push("document.getElementById(\'text\').value=str;");
x.push("}");
x.push("");
newwin.document.writeln(x.join(" <br />"));
newwin.document.writeln("{");
newwin.document.writeln("var str=document.getElementById(\'text\').value;");
newwin.document.writeln("str=str.replace(\/\\r\\n\/gm,\"\\r\\n\ \\r\\n\");");
newwin.document.writeln("document.getElementById(\'text\').value=str;");
newwin.document.writeln("}");
newwin.document.writeln(""); 就是加了红色的,一个斜杠,然后打上个空格