java - 一行字符串中,如果最后一个字符为英文字母,则需要判断该字母是否为该单词的结尾,如果不是,则需要将该单词移至下一行,类似排版。
PHPz
PHPz 2017-04-18 09:34:07
0
2
469

现在有这样一个需求,给定一段文字,然后系统进行分行,现在遇到的问题是如果行尾的字符是英文的话,那么还需要判断这个字符是否是英文单词的最后一个,如果不是,那么需要将该单词整个移至下一行。

例如:
let's trade shoes, just to se
e.
这个时候就需要变成如下形式:
let's trade shoes, just to
see.

有小伙伴能提供下代码或者思路吗?

PHPz
PHPz

学习是最好的投资!

reply all(2)
巴扎黑

This question is very difficult and cannot be judgedsee是独立的两个词,还是一个单词see. Unless there is a word dictionary, but there is still this situation:

... with
out ...

withoutwithout 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.

Peter_Zhu

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template