现在有这样一个需求,给定一段文字,然后系统进行分行,现在遇到的问题是如果行尾的字符是英文的话,那么还需要判断这个字符是否是英文单词的最后一个,如果不是,那么需要将该单词整个移至下一行。
例如:
let's trade shoes, just to se
e.
这个时候就需要变成如下形式:
let's trade shoes, just to
see.
有小伙伴能提供下代码或者思路吗?
巴扎黑2017-04-18 09:36:07
This question is very difficult and cannot be judgedse
和e
是独立的两个词,还是一个单词see
. Unless there is a word dictionary, but there is still this situation:
... with
out ...
with
、out
和without
are all existing words, and there will be ambiguity in using a dictionary at this time.
Normal English sentences longer than one line are written as:
more than one l-
ine.
A -
symbol at the end of a line indicates that the word is not finished.
天蓬老师2017-04-18 09:36:07
Normally, there are spaces between words. You can use this to judge.
Split directly with spaces, and then splice. When the length exceeds one line, remove the last splice, change the line, and continue to the next line