JavaScript如何把整篇文章里的空格替换成换行符, 或把每一个句子分离成独立一行?? function sa(){s1.value=c.value.replace(/\s+/g, "\n");}function sb(){s2.value=c.value.replace(/([^\w+ ])/g, "$1\n");} 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!doctype html><html lang="en"><head><meta charset="UTF-8"><title>Document</title></head><body><div><textarea id="c" cols="67" rows="12">You are stupid! Come here. I will tell you the truth. Where you now?</textarea></div><div><textarea id="s1" cols="67" rows="12" readonly="readonly" ondblclick="sa()"></textarea></div><div><textarea id="s2" cols="67" rows="12" readonly="readonly" ondblclick="sb()"></textarea></div><script type="text/javascript">function sa(){ document.getElementById("s1").value=document.getElementById("c").value.replace(/(\w+|\W+)\s*/g,"$1\n");}function sb(){ document.getElementById("s2").value=document.getElementById("c").value.replace(/(.+?[\.\?!;])\s+/g,"$1\n");}</script></body></html> Jquery 简单问题 谁来帮忙注释下Javascript代码的意思。 XMLHttpRequest url参数问题,本地局域网上运行正常,但是一架到外网的服务器上就总是报404错误 为啥我的帖子老是喜欢沉呢 如何去掉数组的重复元素? 关于弹出窗体屏蔽状态栏问题。 jQuery UI中的tab有关闭按钮吗? document.form1.CTag.value 如何去空格啊, 动态添加表格的问题 求一个前端大佬,救命本人写登陆遇到问题,求前端大佬解决 $.getJson跨域请求成功却没返回值 结论文本框怎么得到值
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div><textarea id="c" cols="67" rows="12">You are stupid! Come here. I will tell you the truth. Where you now?</textarea></div><div><textarea id="s1" cols="67" rows="12" readonly="readonly" ondblclick="sa()"></textarea></div>
<div><textarea id="s2" cols="67" rows="12" readonly="readonly" ondblclick="sb()"></textarea></div>
<script type="text/javascript">
function sa(){
document.getElementById("s1").value=document.getElementById("c").value.replace(/(\w+|\W+)\s*/g,"$1\n");
}
function sb(){
document.getElementById("s2").value=document.getElementById("c").value.replace(/(.+?[\.\?!;])\s+/g,"$1\n");
}
</script>
</body>
</html>