现在有这样一个需求,给定一段文字,然后系统进行分行,现在遇到的问题是如果行尾的字符是英文的话,那么还需要判断这个字符是否是英文单词的最后一个,如果不是,那么需要将该单词整个移至下一行。
例如:let's trade shoes, just to see.这个时候就需要变成如下形式:let's trade shoes, just to see.
有小伙伴能提供下代码或者思路吗?
学习是最好的投资!
This question is very difficult and cannot be judgedse和e是独立的两个词,还是一个单词see. Unless there is a word dictionary, but there is still this situation:
se
e
see
... with out ...
with、out和without are all existing words, and there will be ambiguity in using a dictionary at this time.
with
out
without
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.
-
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
This question is very difficult and cannot be judged
se
和e
是独立的两个词,还是一个单词see
. Unless there is a word dictionary, but there is still this situation: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:
A
-
symbol at the end of a line indicates that the word is not finished.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