var trunc='We\'ve all been there.'; function getLeadingHtml (input, maxChars) { var token = /\w+|[^\w<]|<(\/)?(\w+)[^>]*(\/)?>|"; return output; }; trunc = getLeadingHtml(trunc,47) trunc=(trunc+'...'); document.write('
');