This doesn't seem to exist on the internet, so I wrote it. It's not super great, but does the job.
$(document).ready(function () {
$("a").each(function () {
var t = $(this).text();
if(t.length > 30) {
$(this).text(t.replace(/\./g,". ").replace(/\//g, "/ "));
}
});
});
Thanks for the tip. It was really helpful. I wanted to wrap the long URL names in a Drupal block view. I slightly modified your code according to my requirements.
$(“div.view-review-docs”).find(“a”).each(function () {
var str1=$(this).text();
var str2=”n”;
str1 = str1.substr(0,35) + str2 + str1.substr(35);
$(this).text(str1);
});;
Ajinkya Kulkarni / 6:29am / 14 January 2011