javascript逐字断句 [英] javascript break sentence by words
本文介绍了javascript逐字断句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
将完整单词及其后继字符放入数组的好策略是什么.
Whats a good strategy to get full words into an array with its succeeding character.
示例. 这是一个了不起的句子.
Example. This an an amazing sentence.
Array(
[0] => This
[1] => is
[2] => an
[3] => amazing
[4] => sentence.
)
元素0-3将有一个后续空格,因为句点在第4个元素之后.
Elements 0 - 3 would have a succeeding space, as a period succeeds the 4th element.
我的口头禅是.. 嘿,我需要您用空格分隔这些字符, 然后,一旦注入了数组元素的元素宽度达到X, 换行.
My idea in words is to say.. Hey, i need you to split these by spacing character, Then once width of element with injected array elements reaches X, Break into a new line.
请,请不要给出大量的代码.我宁愿写我自己的书,只是告诉我你会怎么做.
Please, gawd don't give tons of code. I prefer to write my own just tell me how you would do it.
推荐答案
查看全文