I hav a string that contains a lot different HTML tags. I want to shorten it to, let's say, maximum 400 characters. The issue I have is:
I need to make shure that I don't leave open HTML tags. So let's say the text ends with
and the cap would be in the middle of the word "whatever", then I can't have
at the end of the string.
So I need a regular expression that does the following:
1) find end of words where I want to do the cut.
2) If an HTML tag would stay open there, then do the cut BEFORE the last HTML tag.
Can anybody help?