This string has 78 characters with HTML and 39 characters without HTML:
<p>I really like the <a href="http://google.com">Google</a> search engine.</p>
I want to truncate this string based on the non-HTML character count, so for example if I wanted to truncate the above string to 24 characters, the output would be:
I really like the <a href="http://google.com">Google</a>
The truncation did not take into account the html when determining the number of characters to cut off, it only considered the stripped count. However, it didn't leave open HTML tags.
See Question&Answers more detail:os