|
Posted by Stefan Rybacki on 09/29/69 11:19
ChrisJ wrote:
> I want to take a plain text string of arbitrary length and reduce its
> lenth to a set maximum. However I want the split to be at a word
> boundary (whitespace) not half way through a word.
>
> Is there an easy solution?
Well, define easy ;)
You could follow the following steps:
1. specify the max length
2. have a look at the textpositions: max,max+1
if one of this characters is a whitespace you just copy max
characters from the text (keep track of text length)
if not, you have to find the last whitespace in the text between
character 0 and character max
Well you don't really need to check the first condition, you just could
search for the first whitespace starting at the position max+1 as long
as max+1 is lower than the length of the text
Hope that helps
Regards
Stefan Rybacki
>
> ChrisJ
Navigation:
[Reply to this message]
|