Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Truncate a string which contains HTML

Status
Not open for further replies.

Badgers

Programmer
Nov 20, 2001
187
US
Hi,

I have a string which contains HTML for eg;

"<strong>the fox jumped over the fence</strong>"

But if I truncate say at character 5, I'd loose the closing tag.

There could also be a range of potential html tags as well.

Anyone has any slick ideas how to write a routine, to add the closing tags back after a string cut.

Thanks
 
You would probably have to write some complicated RegEx with grouping functions. Then figure out what tags you truncated and add them back. This seems like a very complicated task. Good luck. [smile]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top