擅长:python、mysql、java
<p>如果您只是在寻找能够做到这一点的javascript,那么可以这样做:</p>
<pre><code>var str = "Lorem ipsum 4.00 dolor sit amet, consectetur adipiscing elit. Vestibulum aliquet leo in urna hendrerit placerat. Donec adipiscing dignissim adipiscing. Duis adipiscing mollis cursus. Etiam fringilla elit nec enim sagittis a auctor nisi gravida. Nunc etc.... sollicitudin, leo sit amet consequat pharetra, mi orci vestibulum mi, a suscipit odio tellus tincidunt erat. Suspendisse a consequat turpis. Morbi eget ante leo, a dignissim mi."
str = str.replace(/(\S\.)\s*([A-Z])/g, "$1\n$2");
</code></pre>
<p>你可以看到它在这里工作:<a href="http://jsfiddle.net/jfriend00/NR5Nc/" rel="nofollow">http://jsfiddle.net/jfriend00/NR5Nc/</a>。在</p>
<p>这种特殊的算法只在非空白后加句点后加空格后加大写字母的换行符。所以,它不受<code>$4.00</code>和{<cd2>}之类的东西的影响,它们实际上并不结束行。它对行之间的空白量也很灵活。在</p>