What about:
var text= $('div.contentdetail').text();
var match= text.match( /^(.{100}([^ .]{0,20}[ .])?)(.{20,})$/ );
if (match!==null) {
var visibleText = match[1];
var textToHide = match[3];
...do replacement...
}
{0,20} 20 , 100 . . {20,} , .
, :
.html(visibleText + ('<span>' + textToHide + '</span>'))
HTML - . visibleText textToHide - < &, , XSS .
text() div span , , .