Javascript-如何添加';br';成段
我正在使用backbone.js进行我的移动应用程序项目。我的问题是如何在段落中添加“br”?这是我的密码Javascript-如何添加';br';成段,javascript,backbone.js,Javascript,Backbone.js,我正在使用backbone.js进行我的移动应用程序项目。我的问题是如何在段落中添加“br”?这是我的密码 <p><%= product.get('description') %></p> 我想要的是这样 The COOLPIX S620 combines beauty and brains. It features the worlds fastest start up in just 0.7 seconds. 不是这个 The COOLPIX S6
<p><%= product.get('description') %></p>
我想要的是这样
The COOLPIX S620 combines beauty and brains.
It features the worlds fastest start up in just 0.7 seconds.
不是这个
The COOLPIX S620 combines beauty and brains. It features the worlds fastest start up in just 0.7 seconds.
您可以在javascript中使用正则表达式在每个句子后添加换行符 后跟大写字母的期间的搜索参数为
/\(?=[a-Z])/g
description.replace(/\.(?=[A-Z])/g,
);
按拆分
加入
@elclanrs-这会有点风险,因为他可能会在他们不应该在的地方拥有
。例如:0.7
将变为0
7
是的,只是在那里给出一个提示,希望OP会尝试一些东西并发布代码什么界定了你的段落?新行?如果他按
分开,那么段落中使用的仅为0.7
呢?
The COOLPIX S620 combines beauty and brains. It features the worlds fastest start up in just 0.7 seconds.
description.replace(/\.(?=[A-Z])/g, '<br />');